search for: mod2

Displaying 20 results from an estimated 126 matches for "mod2".

Did you mean: mod
2010 Jan 28
2
Data.frame manipulation
...e of effect size for each study. This results in a reduced # of rows. I am particularly interested in simply reducing the additional variables in the data.frame to the first row of the corresponding id variable. For example: id<-c(1,2,2,3,3,3) es<-c(.3,.1,.3,.1,.2,.3) mod1<-c(2,4,4,1,1,1) mod2<-c("wai","other","calpas","wai","itas","other") data<-as.data.frame(cbind(id,es,mod1,mod2)) data id es mod1 mod2 1 1 0.3 2 wai 2 2 0.1 4 other 3 2 0.2 4 calpas 4 3 0.1 1 itas 5 3 0...
2012 Jun 06
3
Sobel's test for mediation and lme4/nlme
...out, grpid=grpid) NEWDAT <- na.exclude(NEWDAT) model1 <- lme(out ~ pred, random=~1|grpid,data = NEWDAT) model2 <- lme(out ~ pred + med, random=~1|grpid, data = NEWDAT) model3 <- lme(med ~ pred, random=~1|grpid, data = NEWDAT) mod1.out <- summary(model1)$tTable mod2.out <- summary(model2)$tTable mod3.out <- summary(model3)$tTable indir <- mod3.out[2, 1] * mod2.out[3, 1] effvar <- (mod3.out[2, 1])^2 * (mod2.out[3, 2])^2 + (mod2.out[3, 1])^2 * (mod3.out[2, 2])^2 serr <- sqrt(effvar) zvalue = indir/serr out <- lis...
2010 Sep 26
1
formatting data for predict()
...g x2 constant at 0 like this: p2=predict(mod, type="response", newdata=as.data.frame(cbind(x1, x2=0))) unique(p2) However, I am running regressions as part of a function I wrote, which feeds in the independent variables to the regression in matrix form, like this: dat=cbind(x1, x2) mod2=glm(y ~ dat, family=binomial) The results are the same as in mod. Yet I cannot figure out how to input information into the "newdata" option of predict() in order to generate the same predicted probabilities as above. The same code as above does not work: p2a=predict(mod2, type=...
2013 Feb 12
0
error message from predict.coxph
...), X2=rep(0:1, 2))) # model with 2 effects mod <- coxph(Surv(Time) ~ X + X2, data=thedata) summary(mod) # coefficient of X2 should be 0 # coefficient of X should be log(lambda1/lambda0) log(lambda1/lambda0) predict(mod , newdata=ndf, type="expected", se.fit=TRUE) # stratified model mod2 <- coxph(Surv(Time) ~ strata(X) + X2, data=thedata) predict(mod2, newdata=ndf, type="expected" ) # no se predict(mod2, newdata=ndf, se.fit=TRUE) # type="lp" predict(mod2, type="expected", se.fit=TRUE) # prediction at old dat...
2011 Oct 26
2
Error in summary.mlm: formula not subsettable
...en I fit a multivariate linear model, and the formula is defined outside the call to lm(), the method summary.mlm() fails. This works well: > y <- matrix(rnorm(20),nrow=10) > x <- matrix(rnorm(10)) > mod1 <- lm(y~x) > summary(mod1) ... But this does not: > f <- y~x > mod2 <- lm(f) > summary(mod2) Error en object$call$formula[[2L]] <- object$terms[[2L]] <- as.name(ynames[i]) : objeto de tipo 'symbol' no es subconjunto I would say that the problem is in the following difference: > class(mod1$call$formula) [1] "call" > class(mod2$...
2013 Nov 25
4
lmer specification for random effects: contradictory reults
...&bvm> R.H. et al 2008) Here, dT_purs is the response variable, T and Z are the fixed effects, and subject is the random effect. Random and fixed effects are crossed.: mod0 <- lmer(dT_purs ~ T + Z + (1|subject), data = x) mod1 <- lmer(dT_purs ~ T + Z + (1 +tempo| subject), data = x) mod2 <- lmer(dT_purs ~ T + Z + (1 +tempo| subject) + (1+ Z| subject), data = x) mod3 <- lmer(dT_purs ~ T * Z + (1 +tempo| subject) + (1+ Z| subject), data = x) mod4 <- lmer(dT_purs ~ T * Z + (1| subject), data = x) anova(mod0, mod1,mod2, mod3, mod4) Data: x Models: mod0: dT_purs ~ T +...
2010 Feb 15
2
creating functions question
...mple (the actual function will involve more than what Im presenting but is irrelevant for the example): # sample data: id<-rep(1:20) n<-c(10,20,13,22,28,12,12,36,19,12,36,75,33,121,37,14,40,16,14,20) r<-c(.68,.56,.23,.64,.49,-.04,.49,.33,.58,.18,-.11,.27,.26,.40,.49, .51,.40,.34,.42,.16) mod2<-factor(c(rep(c(1,2,3,4),5))) da<-data.frame(id, n, r, mod1, mod2) reg0<-lm(da$r ~ 1) reg1<-lm(da$r ~ da$mod1) reg2<-lm(da$r ~ da$mod1 + da$mod2) # This is as far as I get with the function: MRfit <- function( ...) { models <- list(...) fit<- anova(models) return(fit)...
2023 Nov 30
1
back tick names with predict function
...), `plant-density` = c(137, 107, 132, 135, 115, 103, 102, 65, > ?????????????????????? 149, 85, 173, 124, 157, 184, 112, 80, 165, 160, > 157, 119)), > class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -20L)) > > # regression model works > mod2 = lm(`cob-wt` ~ `plant-density`, data = cob) > > # x sequence for plotting CI's > # Set up x points > x = seq(min(cob$`plant-density`), max(cob$`plant-density`), length = 1000) > > # Use predict to get CIs for a plot > # Add CI for regression line (y-hat uses 'c')...
2010 Jul 09
1
output without quotes
...and am struggling to do it properly. The tough part is that I am interested in using these column names for a function within a function (e.g., lm() within a wrapper function). Therefore, cat() doesnt seem appropriate and print() is not what I need. Ideas? # sample data mod1 <- rnorm(20, 10, 2) mod2 <- rnorm(20, 5, 1) dat <- data.frame(mod1, mod2) # collapsing the colnames to 'mod1+mod2' temp <- paste(names(dat), collapse="+") temp # this gives quotes print(temp, quote = FALSE) # no quotes but includes [1] # need the output like this (no quotes & no [1]):...
2008 Oct 16
1
lmer for two models followed by anova to compare the two models
...REMLdeviance 4102 4670 -1954 3665 3908 Random effects: Groups Name Variance Std.Dev. id (Intercept) 0.11562 0.34003 Residual 0.22765 0.47713 number of obs: 2568, groups: id, 107 run this model (only difference is I've removed the interaction term): mod2 <- lmer(x~category+subcomp+(1|id),data=impchiefsrm) obtain this summary result: Linear mixed-effects model fit by REML Formula: x ~ category + subcomp + (1 | id) Data: impchiefsrm AIC BIC logLik MLdeviance REMLdeviance 3987 4151 -1966 3823 3931 Random effects: Groups N...
2003 Feb 10
2
problems using lqs()
...y ~ x1 + x2, method="lms", nsamp="exact") mod1$coefficients (Intercept) x1 x2 35.5293489 0.4422742 -1.2944534 mod1$bestone [1] 12 17 27 Now, instead of using the formula, I want to provide the design matrix and the response, then: X <- cbind(1, x1, x2) mod2 <- lqs.default(X, y, intercept=F, method="lms", nsamp="exact") mod2$coefficients x1 x2 35.4217275 0.4276641 -1.2834731 mod2$bestone [1] 6 14 15 The results are not the same (?!). Furthermore, if I create the design matrix without the column of 1&...
2007 Jun 11
1
2 iosnoop scripts: different results
...ndows were producing different results. I was not able to answer why this is. Can anyone explain this. Here are the reults from the two windows: # io.d ... sched 0 <none> 1024 dad1 W 0.156 bash 1998 /dtrace/mod2 1024 dad1 R 8.807 bash 5184 /usr/bin/ls 8192 dad1 R 10.332 ls 5184 /dtrace/mod2/examples 1024 dad1 R 0.259 fsflush 3 /var/tmp/dtrace-1b 8192 dad1 W 0.278 # io.d ......
2023 Nov 30
1
back tick names with predict function
...224, 257, 200, 190, 208, 224 ), `plant-density` = c(137, 107, 132, 135, 115, 103, 102, 65, ?????????????????????? 149, 85, 173, 124, 157, 184, 112, 80, 165, 160, 157, 119)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -20L)) # regression model works mod2 = lm(`cob-wt` ~ `plant-density`, data = cob) # x sequence for plotting CI's # Set up x points x = seq(min(cob$`plant-density`), max(cob$`plant-density`), length = 1000) # Use predict to get CIs for a plot # Add CI for regression line (y-hat uses 'c') # usual trick is to assign x to ac...
2009 Oct 21
1
How to find the interception point of two linear fitted model in R?
...ns, as shown below. ###################### x <- 1:10 y <- c(1,3,2,4,5,10,13,15,19,22) plot(x,y) ###################### Two fitted? models, with ranges of [1,5] and [5,10],?can be easily fitted separately by lm function as shown below: ####################### mod1 <- lm(y[1:5] ~ x[1:5]) mod2 <- lm(y[5:10] ~ x[5:10]) ####################### I'm looking for the interception points between these two straight lines from these fitted models, mod1 and mod2. Could someone advice me the way to do it? Thank you Fir?
2008 Sep 23
0
OQO mod2 arrival
My OQO mod2s just arrived! All 4 of them; portable testbed here it comes!!! I hope.... The units weigh in at ~.75lbs, and measure aprox. 5 5/8 x 3 3/8 x 1 1/8" A little larger when you push up the 5" screen to reveal the keyboard. WiFi, Bluetooth, HDMI, and a single USB built in; an adapter for...
2006 Dec 09
1
abline for intercept-only simple lm models (with and without offset)
...data = cars) abline(reg = mod) # nothing appears This behaves as documented, but might catch someone. Would it be an improvement if this situation was detected so as to plot the appropriate horizontal line, i.e. abline(a = coef(mod), b = 0) ? Would it also be an improvement if for a model like mod2 <- lm(dist ~ 1 + offset(speed), data = cars) abline(reg = mod2) would be equivalent to abline(a = coef(mod2), b = 1) ? For models through the origin, the current function works fine, but one might even consider models through the origin and having the independent variable in an offset() to be...
2011 Aug 23
1
P values for vglm(zibinomial) function in VGAM
Hi , I know this question has been asked twice in the past but to my knowldege, it still hasn't been solved. I am doing a zero inflated binomial model using the VGAM package, I need to obtain p values for my Tvalues in the vglm output. code is as follows > mod2=vglm(dmat~Season+Diel+Tidal.phase+Tidal.cycle,zibinomial, data=mp1) > summary(mod2) Call: vglm(formula = dmat ~ Season + Diel + Tidal.phase + Tidal.cycle, family = zibinomial, data = mp1) Pearson Residuals: Min 1Q Median 3Q Max logit(phi) -3.6496 0.273...
2011 Mar 19
1
strange PREDICTIONS from a PIECEWISE LINEAR (mixed) MODEL
...y) abline(v=-1,col=2,lty=2) mod<-lm(y~x+x*(x>-1)) summary(mod) yy<-predict(mod) lines(x[order(x)],yy[order(x)],col=2,lwd=2) #--lme #grouping factor, unbalanced g<-as.character(c(1:200)) id<-sample(g,size=1000,replace=T, prob=sample(0:1,200,rep=T)) table(id) #unbalanced mod2<-lme(y~x+x*(x>-1),random=~x|id, data=data.frame(x,y,id)) summary(mod2) newframe<-data.frame( #fictious id id="fictious", x) newframe[1:5,] #predictions yy2<-predict(mod2,level=0, newdata=newframe) lines(x[order(x)],yy2[order(x)],col="blue",lwd=2) # add va...
2013 May 02
1
multivariate, hierarchical model
...ars that CL2_Free is the most significantly correlated so i've decided to include that in the final model. Positively skewed I'm thinking of doing a mixed effects model with random intercepts as the treatment code and zones within the treatment cose and random slopes as the seasons. mod2 <- lme(tthm ~ cl2free, random= ~ seasons| treatcode/loc_code) but that doesn't work. these seems to work good: mod2 <- lme(tthm ~ cl2free, random= ~ 1| loc_code, data=new.data, method="ML") mod3 <- lme(tthm ~ cl2free, random= ~ 1| treatcode/loc_code, d...
2006 Aug 29
2
lattice and several groups
Dear R-list, I would like to use the lattice library to show several groups on the same graph. Here's my example : ## the data f1 <- factor(c("mod1","mod2","mod3"),levels=c("mod1","mod2","mod3")) f1 <- rep(f1,3) f2 <- factor(rep(c("g1","g2","g3"),each=3),levels=c("g1","g2","g3")) df <- data.frame(val=c(4,3,2,5,4,3,6,5,4), x=rep(c(1,2,3),3...