Displaying 20 results from an estimated 87 matches for "newdat".
Did you mean:
newdata
2010 Sep 11
3
confidence bands for a quasipoisson glm
...quasipoisson, data = beva)
summary(gm6)
library('VIM')
b_dist_min_new <- as.numeric(prepare(beva$dist_min, scaling="classical", transformation="logarithm")).
My first steps for the solution are following:
range(b_dist_min_new)
x <- seq(-1.496, 1.839, by=0.01)
newdat <- data.frame(b_dist_min_new=x)
y <- predict(gm6, newdata=newdat, type="response")
plot(x,y, type="l", ylim=c(0,15), lty=2, xlab="Distance [scaled log.]", ylab="Number of used plant", las=1)
ilogit<-function(x) exp(x)/(1 + exp(x))
logit <-functio...
2009 Feb 08
5
glmmBUGS: logistic regression on proportional data
...yone could help me specify the model correctly.
I am trying to specify the response variable, /yseed/, as # of successes
out of total observations... but I suspect that given the error below,
that is not correct. Also, Newsect should be a factor, whereas Newdist
is continuous.
Thanks,
John
Newdat<-data.frame(Newtree=rep(1:3, each=20), Newsect=rep(c("a","b"),
each=10), Newdist=rep(1:5, 2),
y=rpois(60,2), tot=rep(c(14,12,10,8,6), 12))
yseed<-cbind(Newdat$y, Newdat$tot)
mod<-glmmBUGS(yseed~Newsect + Newdist, effects="Newtree",
famil...
2012 Jun 06
3
Sobel's test for mediation and lme4/nlme
...(even though it uses S4 classes) but am not sure
whether this violates any assumptions made by the Sobel test. Also, I wish
to include a matrix of predictors as opposed to a single vector "pred" -
trivial to implement but is it kosher?
sobel.lme<-function (pred, med, out, grpid)
{
NEWDAT <- data.frame(pred = pred, med = med, out = 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...
2017 Aug 09
3
Plotting log transformed predicted values from lme
...want to save the predicted values from that model and show the log curve
in a plot ; predicted~log(x)
mod<-lme(B~log(x)+as.factor(y), random=~1|cohort/Study,
weights=varFixed(~I(SE^2)), na.action=na.omit, data=subset(meta),
control = lmeControl(sigma = 1, apVar = FALSE))
summary(mod)
newdat <- data.frame(x=seq(min(meta$x), max(meta$x),,118)) # I have 118
observations. #How do I add the factor variable to my newdat?
newdat$pred <- predict(mod, newdat,level = 0,type="response")
plot(B ~ x, data=meta)
lines(B ~ x, data=newdat)
Can you please assist me ?
Thank you!
Al...
2006 Oct 20
1
Questions about date/time and truncating
...rly_met_data$date <- as.POSIXct(hourly_met_data$date)
works exactly as it is supposed to (e.g. Min/max of that field are
calculated correctly). However, when I perform this command to convert a
date/time to just a date (e.g. I'm removing the hour portion of the
date/time):
hourly_met_data$newdate <- trunc(hourly_met_data$date,"day")
I get:
Error in `$<-.data.frame`(`*tmp*`, "newdate", value = list(sec = 0, min = 0,
:
replacement has 9 rows, data has 252020
If I simply set:
newdate <- trunc(hourly_met_data$date,"day")
And then print the data (e...
2004 Jan 08
3
Strange parametrization in polr
...ode for reproduction, below the results.
------------------------------------------------------------------------
---
version
library( MASS )
data( housing )
hnames <- lapply( housing[,-5], levels )
house.plr <- polr( Sat ~ Infl + Type + Cont, data=housing, weights=Freq
)
summary( house.plr )
newdat <- expand.grid( hnames[-1] )[1:5,]
cbind( newdat, predict( house.plr, newdat, type="probs" ) )
# Baseline probs:
diff( c(0,tigol( c(-0.4961,0.6907) ), 1) )
# First level of Infl:
diff( c(0,tigol( c(-0.4961,0.6907) + 0.5663922 ), 1) )
# But the change of sign for eta is needed to reprod...
2017 Aug 10
0
Plotting log transformed predicted values from lme
...that model and show the log curve
> in a plot ; predicted~log(x)
>
> mod<-lme(B~log(x)+as.factor(y), random=~1|cohort/Study,
> weights=varFixed(~I(SE^2)), na.action=na.omit, data=subset(meta),
> control = lmeControl(sigma = 1, apVar = FALSE))
> summary(mod)
>
> newdat <- data.frame(x=seq(min(meta$x), max(meta$x),,118)) # I have 118
> observations. #How do I add the factor variable to my newdat?
> newdat$pred <- predict(mod, newdat,level = 0,type="response")
>
> plot(B ~ x, data=meta)
> lines(B ~ x, data=newdat)
>
> Can you p...
2007 Aug 04
2
Problems using "lm" in combination with "predict"
...ression model but it does not work.
My Model: y = Worktime + Vacation + Illnes + Bankholidays
My modelmatrix is of dimension 28x4
Then I want to make use of the function predict because there confidence.intervals are include.
My idea was:
mod <- lm(y~Worktime+Vacation+Illnes+Bankholidays)
newdate=data.frame(x=c(324,123,0.9,0.1))
predict(y,newdate)
But I always get the message:
'newdata' had 1 rows but variable(s) found have 28 rows
What can I do?
Yours,
Maja
--
Psssst! Schon vom neuen GMX MultiMessenger geh?rt?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
2011 Sep 08
1
predict.rma (metafor package)
...# Random Effects
model1<-rma(g,var.g,mods=~mid,method="REML") # covariate model
model2<-rma(g,var.g,mods=~mod,method="REML") # factor model
model3<-rma(g,var.g,mods=~mid+mod,method="REML") # multiple
# example matrix for predicting against model3
newdat<-expand.grid(c(1,2,3,4,5),c(1,2,3))
predict(model1,newmods=c(1,2,3,4,5))
predict(model2,newmods=c(1,2,3))
predict(model3,newmods=newdat)
--
Andrew Beckerman
Sent with Sparrow (http://bit.ly/sigsprw)
[[alternative HTML version deleted]]
2017 Aug 10
1
Plotting log transformed predicted values from lme
...ve
>> in a plot ; predicted~log(x)
>>
>> mod<-lme(B~log(x)+as.factor(y), random=~1|cohort/Study,
>> weights=varFixed(~I(SE^2)), na.action=na.omit, data=subset(meta),
>> control = lmeControl(sigma = 1, apVar = FALSE))
>> summary(mod)
>>
>> newdat <- data.frame(x=seq(min(meta$x), max(meta$x),,118)) # I have 118
>> observations. #How do I add the factor variable to my newdat?
>> newdat$pred <- predict(mod, newdat,level = 0,type="response")
>>
>> plot(B ~ x, data=meta)
>> lines(B ~ x, data=newdat)...
2008 Jul 09
2
sorting a data frame by rownames
...each chunk is going through a loop and being
spit out in a list
sub3<-subset(ex.dat, c=="3")
sub2<-subset(ex.dat, c=="2")
sub1<-subset(ex.dat, c=="1")
#put it back together; in my case, pull out the parts of the list generated
by the loop that hold the data
newdat<-rbind(sub3, sub2, sub1)
#rebuild it such that it can be re-organized into it's original order
rn<-as.numeric(row.names(newdat))
new2<-data.frame(newdat, rn)
new3 = new2[do.call(order, new2["rn"]), ]
######################
It's those last three lines of code that I&...
2007 Feb 01
2
Losing factor levels when moving variables from one context to another
...725649 30
7 1.49001721222926 30
8 2.00587718501980 30
9 0.450576585429981 30
10 2.87120375367357 30
11 2.25575058079324 80
12 2.03471288724508 80
13 2.67432066972984 80
14 1.74102136279177 80
15 2.29827581276955 80
and now:
newvar<-(rnorm(15,4))
newdat<-as.data.frame(cbind(newvar, dat$vecs))
newdat
R returns:
newvar V2
1 4.300788 1
2 5.295951 1
3 5.099849 1
4 3.211045 1
5 3.703554 1
6 3.693826 2
7 5.314679 2
8 4.222270 2
9 3.534515 2
10 4.037401 2
11 4.476808 3
12 4.842449 3
13 3.109677 3
14 4.752961 3
15 4.4452...
2012 Apr 18
3
normal distribution assumption for multi-level modelling
...nt of
a lexical decision task). To ascertain that the data was normally
distributed, I used *shapiro.test *for each participant (see commands
below), but only one out of 21 returns a p value above p.0 05.
> f = function(dfr) return(shapiro.test(dfr$Target.RTinv)$p.value)
> p = as.vector(by(newdat, newdat$Subject, f))
> names(p) = levels(newdat$Subject)
> names(p[p < 0.05])
Removing a few outliers per subject doesn't make a difference, and
"aggressive" removal of outliers (done by subject, for each of the 6
conditions ) still results in non-normally distributed data b...
2011 Jun 24
2
mgcv:gamm: predict to reflect random s() effects?
....gamm <- gamm( Y ~ Group + s(X, by=Group), random = list(Subject=~1) )
Y and X are numeric, Group is an unordered factor with 5 levels, and Subject is an unordered factor with ~70 levels
Now the output from gamm is a list with an lme component and a gam component. If I make a data frame "newdat" like this:
> newdat
X Group Subject
5 g1 s1
5 g1 s2
5 g1 s3
6 g1 s1
6 g1 s2
6 g1 s3
I can get the fixed effects prediction of the smooth by...
2004 May 26
2
Subtracting number of days from a date
Hi group,
suppose I have a date, say May 15 2004, and I want to now what date it is 23 days before that date. The way to calculate the new date should (...) take account of leap years :)
In pseudocode:
olddate <- "May 15 2004"
newdate <- olddate-23
I looked around in POSIXct etc..., maybe I overlooked?
Thanks,
Maarten
--------------------------------------------------------------
Zie ook/see also: http://www.knmi.nl/maildisclaimer.html
2011 Apr 04
1
Clarks 2Dt function in R
Dear Ben,
you answerd to Nancy Shackelford about Clarks 2Dt function.
Since the thread ended just after your reply,
I would like to ask, if you have an idea how to use this function in R
I defined it the following way:
function(x , p, u) {
(p/(pi*u))*(1+(x^2/u))^(p+1)
}
and would like to fit this one to my obeservational data (count)
[,1] [,2]
[1,] 15 12
[2,] 45 13
[3,]
2005 May 13
1
manipulating dataframe according to the values of some columns
hi netters,
I'm a newbie to R and there are some very simple problems puzzeled me for
two days.
I've a dataframe here with several columns different in modes. Two of the
columns are special for me: column 1 has the mode "factor" and column 2 has
the mode "numeric vectors".
The values for column 1 are either "T" or "F". I wanna do two things:
2005 May 24
3
obtaining first and last record for rows with same identifier
I have a dataframe that contains fields such as patid, labdate, labvalue.
The same patid may show up in multiple rows because of lab measurements on
multiple days. Is there a simple way to obtain just the first and last
record for each patient, or do I need to write some code that performs that.
Thanks,
Steven
2009 Aug 21
2
compare observed and fitted GAM values
Hi,
I am comparing the observed and fitted values of my GAM model, which includes the explanatory variables: longitude, depth, ssh, year and month. When I compare observed and fitted values for longitude, depth and ssh it works. But when I try to do it for month and year (which are as factors in the GAM model) it doesn't work. My observed and fitted values are exactly the same.. How is that
2011 Jun 14
0
error message trying to plot survival curves from hypothetical covariate profiles
...um 0 0 0 0 0 0 0 0 0 0 ...
$ start : num 2005 2005 2005 2006 2006 ...
$ stop : num 2006 2006 2006 2007 2007 ...
$ risk : num 1 2 3 1 2 3 1 2 3 1 ...
$ evstatus: num 0 0 0 0 0 0 0 0 0 0 ...
I am modelling the survival time until the adoption of the policy as follows:
mod1<-Surv(newdat$start, newdat$stop, newdat$evstatus)
mymod1<-coxph(mod1 ~ news + enviro + partisan + cluster(state) + strata(evstatus), method=c("efron"), robust=TRUE)
Again, following Fox, I try to construct a data frame with a hypothetical covariate profile:
n<-data.frame(news=rep(c(1,4,8)), ev...