tag:blogger.com,1999:blog-1275149608391671670.post4816464180377623548..comments2023-09-28T06:13:40.704-04:00Comments on SAS and R: Example 7.20: Simulate categorical dataKen Kleinmanhttp://www.blogger.com/profile/09525118721291529157noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-1275149608391671670.post-82738200598769941012013-05-13T11:04:33.962-04:002013-05-13T11:04:33.962-04:00What is the variance of the error term when a mult...What is the variance of the error term when a multinomial logit is simulated in this way?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-61588336692095624392012-03-31T09:31:21.179-04:002012-03-31T09:31:21.179-04:00There is a literature that might be relevant. A s...There is a literature that might be relevant. A starting point might be Cox, D. R. and Wermuth, N. (1992). Response models for mixed binary and quantitative variables. Biometrika, 79, 441-461. They propose a flexible multivariate distribution which might be useful.Nick Hortonhttps://www.blogger.com/profile/00242216324355342047noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-7294328340859254802012-03-30T22:20:09.000-04:002012-03-30T22:20:09.000-04:00Good to know about that one, thanks. I don't ...Good to know about that one, thanks. I don't know of a technique to do what you need, offhand. A brief search turned up this thread: http://stats.stackexchange.com/questions/22856/how-to-generate-correlated-test-data-that-has-bernoulli-categorical-and-contin where copulas are suggested. And also this paper: http://www.springerlink.com/content/011x633m554u843g/. Let me know what you end up doing.Ken Kleinmanhttps://www.blogger.com/profile/09525118721291529157noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-15407082092789234612012-03-30T21:27:05.528-04:002012-03-30T21:27:05.528-04:00Thanks for the response.
There is an R package cal...Thanks for the response.<br />There is an R package called "bindata". It performs almost perfect to create correlated binary variables, with known marginal probabilities and correlations.<br />What I need is the simulation of correlated continuous and categorical variables using a single multivariate distribution.burakaydinhttps://www.blogger.com/profile/01651029406532275572noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-40166747202310059182012-03-30T20:24:10.991-04:002012-03-30T20:24:10.991-04:00In example 6.3 in our book, we show correlated bin...In example 6.3 in our book, we show correlated binary variables, based on Lipsitz et al, Stats in Med 1990, 9:1517-1525. You'll find many cites if you search with "simulate correlated" as your base.Ken Kleinmanhttps://www.blogger.com/profile/09525118721291529157noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-17589082297937442022012-03-30T17:48:02.615-04:002012-03-30T17:48:02.615-04:00Hello,
Can I simulate variables with a known Pears...Hello,<br />Can I simulate variables with a known Pearson covariance matrix?<br />I need to simulate categorical, continuous and binary variables based on the pearson covariance matrix? thanksburakaydinhttps://www.blogger.com/profile/01651029406532275572noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-74114330380214750532011-04-19T12:36:25.360-04:002011-04-19T12:36:25.360-04:00I'm not sure what you're asking. You can ...I'm not sure what you're asking. You can simulate data from a multinomial logistic model using a process similar to what we show for logistic regression in this entry: http://sas-and-r.blogspot.com/2009/06/example-72-simulate-data-from-logistic.html. What do you mean by a "metric" variable, though?Ken Kleinmanhttps://www.blogger.com/profile/09525118721291529157noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-39037219934073471082011-04-19T10:21:04.760-04:002011-04-19T10:21:04.760-04:00Hello,
how could I simulate data from a multinomi...Hello,<br /><br />how could I simulate data from a multinomial logit model depending on a metric variable.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-87379094132971011802010-01-08T04:36:44.690-05:002010-01-08T04:36:44.690-05:00Sample may be a better function to simulate catego...Sample may be a better function to simulate categorical data:<br /><br />> sample(1:4,10000,rep=TRUE,prob=c(.1,.2,.3,.4))<br />> table(sample)<br /><br /> 1 2 3 4 <br />1012 2074 2924 3990Unknownhttps://www.blogger.com/profile/13636847841950806506noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-57596293854967529132010-01-05T08:43:32.722-05:002010-01-05T08:43:32.722-05:00Thanks, Douglas! Much better.
It looks like if I...Thanks, Douglas! Much better.<br /><br />It looks like if I omit the labels=FALSE, the factor labels are very useful, too.<br /><br />> mycat <- cut(runif(10000), c(0, 0.1, 0.3, 0.6, 1))<br /><br />> summary(mycat)<br /> (0,0.1] (0.1,0.3] (0.3,0.6] (0.6,1] <br /> 987 1993 3047 3973Ken Kleinmanhttps://www.blogger.com/profile/09525118721291529157noreply@blogger.comtag:blogger.com,1999:blog-1275149608391671670.post-47684649739666550782010-01-04T22:53:35.221-05:002010-01-04T22:53:35.221-05:00Or, you could just use
mycat <- cut(runif(1000...Or, you could just use<br /><br />mycat <- cut(runif(10000), c(0, 0.1, 0.3, 0.6, 1), labels=FALSE)Douglas Rivershttps://www.blogger.com/profile/11786819042727788153noreply@blogger.com