Mª Teresa Martinez Soriano
2013-Nov-11 22:52 UTC
[R] colours legend, for loop,density plot
Hi , thanks in advance I have the follow code:
normal<-sort(rnorm(1000)) cauchy<-sort(rcauchy(1000))
t3<-sort(rt(1000,3)) t10<-sort(rt(1000, 10))
col<-c("green","blue","orange","purple")
v<-list(normal,cauchy,t3,t10) names(v)<-c("Normal",
"Cauchy", "T-stud 3 df", "T-stud 10 df")
par(mfrow=c(1,2)) plot(density(normal),col=col[[1]],main="Funciones de
densidad") for ( i in 2:4) { lines(density(v[[i]]),col=col[[i]],lty=i+2) }
legend(x=-4,y=0.3,names(v),col=col,cex=0.6)
The problem is that in the legend doesn't appear colours so I can not
identify which curve is each one, please could you tell me what do I neet to
change in order to solve it??
Thanks a lot, Tere
[[alternative HTML version deleted]]
On 11/12/2013 09:52 AM, M? Teresa Martinez Soriano wrote:> normal<-sort(rnorm(1000)) cauchy<-sort(rcauchy(1000)) t3<-sort(rt(1000,3)) t10<-sort(rt(1000, 10)) > col<-c("green","blue","orange","purple") v<-list(normal,cauchy,t3,t10) names(v)<-c("Normal", "Cauchy", "T-stud 3 df", "T-stud 10 df") > par(mfrow=c(1,2)) plot(density(normal),col=col[[1]],main="Funciones de densidad") for ( i in 2:4) { lines(density(v[[i]]),col=col[[i]],lty=i+2) } > legend(x=-4,y=0.3,names(v),col=col,cex=0.6) >Hi Tere, Try this: legend(x=-2,y=0.04,names(v),col=col,cex=0.6,lty=c(1,4:6)) Jim
Mª Teresa Martinez Soriano
2013-Dec-02 11:03 UTC
[R] Confidence interval, multiple imputation
Hi to
everyone, I have a big data set where rows are observations and columns are
variables. It contains a lot of missing values. I have used multiple imputation
with library mice and I get an “exact” prediction of each missing value. Now, I
would like to know the error I can commit or the confidence interval.
How can I
get this?
This is
part of my code
library(mice)
mod1<-mice(dat,
method=c("","",rep("pmm",6)))
ro<-round(cor(dat,
use = "pair"), 3)
predictor<-quickpred(dat)#
esta matriz predictora se construye según las correlaciones
mod1<-mice(dat,method=c("","",rep("pmm",6)),
pred=predictor)
imputados<-complete(mod1,'long')
x.imp=split(imputados,
imputados$.imp)
acumula=x.imp[[1]][,-c(1,2)]
for(j
in 2:length(x.imp))
{
acumula=acumula+x.imp[[j]][,-c(1,2)]}
med.imp=acumula/5
Thanks in
advance
[[alternative HTML version deleted]]