楼主: Lisrelchen
3804 14

R2MLwiN [推广有奖]

11
Lisrelchen 发表于 2013-12-10 00:28:49
Examples:Draws a sixway plot of MCMC diagnostics.
## Not run:
library(R2MLwiN)
## Modify the following paths as appropriate.
## MLwiN folder
mlwin = "C:/Program Files (x86)/MLwiN v2.27/"
## MLwiN sample worksheet folder
wspath=paste(mlwin,"/samples/",sep="")
## Example: Normal
formula="normexam~(0|cons+standlrt)+(2|cons+standlrt)+(1|cons)"
levID=c('school','student')
estoptions= list(EstM=1,resi.store.levs=2)
wsfile=paste(wspath,"tutorial.ws",sep="")
inputfile=paste(tempdir(),"/tutorial.dta",sep="")
ws2foreign(wsfile, foreignfile=inputfile, MLwiNPath=mlwin)
library(foreign);indata =read.dta(inputfile)
mymodel=runMLwiN(formula, levID, D="Normal", indata, estoptions,MLwiNPath=mlwin)
chain=mymodel["chains"][,"FP_standlrt"]
sixway(chain,"beta_1")
## End(Not run)

12
Lisrelchen 发表于 2013-12-10 00:33:33

Example: Plots MCMC chain trajectories


## Not run:
library(R2MLwiN)
## Modify the following paths as appropriate.
## MLwiN folder
mlwin = "C:/Program Files (x86)/MLwiN v2.27/"
## MLwiN sample worksheet folder
wspath=paste(mlwin,"/samples/",sep="")
## Example: Normal
formula="normexam~(0|cons+standlrt)+(2|cons+standlrt)+(1|cons)"
levID=c('school','student')
estoptions= list(EstM=1)
wsfile=paste(wspath,"tutorial.ws",sep="")
inputfile=paste(tempdir(),"/tutorial.dta",sep="")
ws2foreign(wsfile, foreignfile=inputfile, MLwiNPath=mlwin)
library(foreign);indata =read.dta(inputfile)
mymodel=runMLwiN(formula, levID, D="Normal", indata, estoptions, MLwiNPath=mlwin)
trajectories(mymodel["chains"],Range=c(4501,5000))
## End(Not run)

13
Lisrelchen 发表于 2013-12-10 00:35:42

Example: Converts a categorical variable into several separate binary variables


## Not run:
library(R2MLwiN)
## Modify the following paths as appropriate.
## MLwiN folder
mlwin = "C:/Program Files (x86)/MLwiN v2.27/"
## MLwiN sample worksheet folder
wspath=paste(mlwin,"/samples/",sep="")
wsfile=paste(wspath,"tutorial.ws",sep="")
inputfile=paste(tempdir(),"/tutorial.dta",sep="")
ws2foreign(wsfile, foreignfile=inputfile, MLwiNPath=mlwin)
library(foreign);indata =read.dta(inputfile)
names(indata)
indata=cbind(indata,Untoggle(indata[["school"]],"school"))
names(indata)

## End(Not run)


14
Lisrelchen 发表于 2013-12-10 00:52:28

15
958163533 在职认证  发表于 2017-7-23 16:24:05
多层次 回归模型 全部变量都放进去 不区分 是不是就是最小二成回归

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-30 13:19