Direkt zum Hauptbereich

#SimulatedData #R #caret

I just noticed a very cool function in the caret-package, I would like to share.
The package can produce simulated data, which is very useful for Monte Carlo Simulations, or when you just want to try something out...
In addition, the psych-package has one of the best correlation tables.


library(caret)
## Loading required package: lattice
## Loading required package: ggplot2
set.seed(1)
df <- twoClassSim(5000, intercept = -13)
## Loading required package: MASS
summary(df)
##    TwoFactor1       TwoFactor2        Linear01         Linear02     
##  Min.   :-4.940   Min.   :-5.017   Min.   :-4.303   Min.   :-3.683  
##  1st Qu.:-0.956   1st Qu.:-0.969   1st Qu.:-0.696   1st Qu.:-0.668  
##  Median : 0.015   Median :-0.021   Median :-0.045   Median : 0.007  
##  Mean   : 0.002   Mean   :-0.010   Mean   :-0.022   Mean   : 0.014  
##  3rd Qu.: 0.978   3rd Qu.: 0.974   3rd Qu.: 0.645   3rd Qu.: 0.669  
##  Max.   : 5.076   Max.   : 5.179   Max.   : 3.728   Max.   : 3.650  
##     Linear03         Linear04         Linear05         Linear06     
##  Min.   :-3.217   Min.   :-3.639   Min.   :-3.825   Min.   :-3.734  
##  1st Qu.:-0.634   1st Qu.:-0.721   1st Qu.:-0.671   1st Qu.:-0.712  
##  Median : 0.053   Median :-0.003   Median : 0.012   Median : 0.009  
##  Mean   : 0.026   Mean   :-0.011   Mean   : 0.014   Mean   :-0.026  
##  3rd Qu.: 0.677   3rd Qu.: 0.691   3rd Qu.: 0.674   3rd Qu.: 0.642  
##  Max.   : 3.560   Max.   : 3.651   Max.   : 3.388   Max.   : 3.810  
##     Linear07         Linear08         Linear09         Linear10     
##  Min.   :-3.586   Min.   :-3.637   Min.   :-4.205   Min.   :-3.733  
##  1st Qu.:-0.677   1st Qu.:-0.714   1st Qu.:-0.694   1st Qu.:-0.648  
##  Median :-0.004   Median :-0.012   Median :-0.004   Median : 0.007  
##  Mean   : 0.009   Mean   :-0.016   Mean   :-0.020   Mean   : 0.000  
##  3rd Qu.: 0.691   3rd Qu.: 0.688   3rd Qu.: 0.650   3rd Qu.: 0.668  
##  Max.   : 3.485   Max.   : 3.533   Max.   : 3.414   Max.   : 3.412  
##    Nonlinear1        Nonlinear2       Nonlinear3        Class     
##  Min.   :-0.9979   Min.   :0.0001   Min.   :0.0002   Class1:4245  
##  1st Qu.:-0.4917   1st Qu.:0.2453   1st Qu.:0.2516   Class2: 755  
##  Median : 0.0016   Median :0.5037   Median :0.4966                
##  Mean   : 0.0037   Mean   :0.4986   Mean   :0.4987                
##  3rd Qu.: 0.5101   3rd Qu.:0.7399   3rd Qu.:0.7426                
##  Max.   : 0.9996   Max.   :0.9999   Max.   :0.9994
library(psych)
## 
## Attaching package: 'psych'
## 
## The following object is masked from 'package:ggplot2':
## 
##     %+%
pairs.panels(df)
plot of chunk unnamed-chunk-1

Kommentare

Beliebte Posts aus diesem Blog

#RTutorial: Using R to Harvest the Twitter STREAM API

Initializing the Twitter API In this tutorial, the so called STREAMING-API from Twitter is used. This API provides real-time access to Twitter, so the results are dependent from what is actually going on, right now. Before we start, we have to initialize the Twitter-API. To use the Twitter API, a consumer key and consumer secret is required. Therefore, you have to register as a developer who is creating a Twitter app. Create a Twitter account and then sign in at https://apps.twitter.com/. The account has to be verified with a phone number. This can be done on the Twitter webpage in the account settings. Fill in name, description and any valid URL with leading “http://”. It is important NOT to provide any call-back URL, because otherwise the registration from R will not function. After this, you can see a summary of your newly created app with a link to “manage keys and access tokens”. The consumer key and consumer secret that can be found there have to be copied into the following R-...

Deep-Dive Impfeffektivität: Eine kritische Datenanalyse der RKI-Berechnungen / Teil 1: Die Methode

Die Einschätzung, wie effektiv die COVID-Impfung ist, ist eine der politisch relevantesten Kennzahlen derzeit. Insbesondere für die Einschätzungen der Angemessenheit einr Impfpflicht ist diese Zahl extrem wichtig. In der Vergangenheit hat sich immer wieder gezeigt, dass die Berechnungen des RKI nicht in jeder Hinsicht eindeutig sind, sondern auf vielen Annahmen beruhen, die man auch kritisch hinterfragen kann und muss. Für die politische Datenwissenschaft ist es daher essenziell, diese Berechnungen nachvollziehbar zu machen. In diesem Beitrag wird das methodische Vorgehen des RKI zur Berechnung der Impfeffektivität analysiert. Die Informationen dazu entstammen den RKI-Wochenberichten .  In einem zweiten Teil habe ich die konkreten Berechnungen des RKI so weit wie möglich rekonstruiert und kann daher zeigen, wie stark die Ergebnisse schwanken, wenn Annahmen leicht verändert werden. Meine Erkenntnisse aus der folgenden Analyse: Das RKI verwendet zur Berechnung der Impfeffektivität di...

The Social Science One Facebook Cooperation: A Systemic Failure

This blogpost is a detailed background statement to this comment published in Nature at https://www.nature.com/articles/d41586-020-00828-5 . Fast-Read The following text argues that the Social Science One initiative that is celebrated by Facebook as success is an systemic failure. Privacy concerns are instrumentalized to withhold data from independent researchers while similar data is still available to private companies. The hurdles for researchers at Social Science One are set in a way that it is nearly impossible to study the effect of social media on elections and democracy. This fits to the strategic interest of Facebook to play cooperative but to control the outcomes of research. Social Science One is structured in a way that it is easy for Facebook to instrumentalize this organization. We end with policy recommendations. An appendix shows that the dataset delivered by Facebook is more or less useless. Background Facebook has announced the release of a dataset that is shar...