tag:blogger.com,1999:blog-4594832939334410220.post886998168894717997..comments2024-02-12T06:23:51.153-06:00Comments on Deeply Trivial: Statistical Sins: Types of Statistical RelationshipsUnknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4594832939334410220.post-62701704004480041542018-02-01T17:24:19.593-06:002018-02-01T17:24:19.593-06:00Thanks for the tip how to plot trend lines!Thanks for the tip how to plot trend lines!Anonymoushttps://www.blogger.com/profile/15768999138674851285noreply@blogger.comtag:blogger.com,1999:blog-4594832939334410220.post-42926127799933450012018-02-01T17:23:13.231-06:002018-02-01T17:23:13.231-06:00"Just looking down the columns, you can see t..."Just looking down the columns, you can see that the correlations are very close to what I specified. The one exception is the correlation between V3 and V4 - I asked for -0.001 and instead have 0.012. Probably, R couldn't figure out how to generate data with that correlation while also coming close to the other values I specified." Not really, that correlation one is 'as off' as most of the rest. It's just sampling error: Calculate the differences between the unique, off-diagonal elements in R and cor(raw) and plot a histogram. You'll obtain a distribution around 0 (which would approximate a normal distribution if the matrices are large). <br /><br />If you want to generate exact data (i.e. population data rather than sample data), you can make use the function mvrnorm (in library MASS), for instance.<br /><br />An example, (run after installing MASS):<br /><br />R <- matrix (scan(), 5, 5, TRUE)<br /> 1 0.6 -0.5 0.31 0.11<br /> 0.6 1 -0.39 -0.25 0.05<br />-0.5 -0.39 1 -0.001 -0.09<br /> 0.31 -0.25 -0.001 1 0.01<br /> 0.11 0.05 -0.09 0.01 1<br /> <br />set.seed(36)<br /><br />nvars <- ncol( R )<br /><br />nobs <- 1000<br /><br />raw <- MASS::mvrnorm( nobs, rep ( 0, nvars ), R, emp = TRUE )<br /><br />cor( raw )<br /><br /># change emp = TRUE to emp = FALSE (the default) in order tot generate sample dataAnonymoushttps://www.blogger.com/profile/15768999138674851285noreply@blogger.comtag:blogger.com,1999:blog-4594832939334410220.post-80521669554518314102018-01-31T15:28:53.384-06:002018-01-31T15:28:53.384-06:00Sounds great, please add to your list. Keep the po...Sounds great, please add to your list. Keep the posts coming!Pete Mikszahttps://www.blogger.com/profile/09113050562733038070noreply@blogger.comtag:blogger.com,1999:blog-4594832939334410220.post-21149624155788597922018-01-31T15:22:29.105-06:002018-01-31T15:22:29.105-06:00Awesome! Thank so much for sharing, Pete! I'll...Awesome! Thank so much for sharing, Pete! I'll check out your apps and let you know if I have any thoughts/feedback. Mind if I add you to my list of Data Science and Statistics resources? http://www.deeplytrivial.com/2017/10/statistics-sunday-free-data-science-and.htmlSarahttps://www.blogger.com/profile/13213593768515404983noreply@blogger.comtag:blogger.com,1999:blog-4594832939334410220.post-63377355310828243972018-01-31T15:14:03.570-06:002018-01-31T15:14:03.570-06:00Hello,
I really enjoy the simplicity and clarity o...Hello,<br />I really enjoy the simplicity and clarity of your posts dealing with unpacking foundational stats concepts. I teach a bit of research methods and made some Shiny apps to demo some similar concepts (here: https://petemiksza.com/visualizing-statistical-concepts/). Maybe the correlation app would be of interest? Also, would appreciate any feedback for improvement if you had any.<br />Thanks for these posts!<br />PetePete Mikszahttps://www.blogger.com/profile/09113050562733038070noreply@blogger.com