Displaying 20 results from an estimated 90 matches similar to: "fitting a model with the nlme package"
2012 Sep 17
6
help with calculation from dataframe with multiple entries per sample
Hi
I have a dataframe similar to:
>Sample<-c(1,1,1,2,2,2,3,3,3)
>Time<-c(1,2,3,1,2,3,1,2,3)
>Mass<-c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5)
>mydata<-as.data.frame(cbind(Sample,Time,Mass))
Sample Time Mass
1 1 1 3.0
2 1 2 3.1
3 1 3 3.4
4 2 1 4.0
5 2 2 4.3
6 2 3 4.4
7 3 1 3.0
8 3 2 3.2
9 3 3
2006 Mar 21
1
Getting polygons from contiguous grid cells having same value in sp
I have been using the sp package to deal with gridded data. I would
like to know how to extract the vertices (x,y) of polygons that outline
areas of like-valued cells in a grid. Here is a simple 3x3 grid:
2 2 1
1 2 1
1 1 3
x <- c(1,1,1,2,2,2,3,3,3) # define a 3 x 3 array of points
y <- c(1,2,3,1,2,3,1,2,3)
h <- SpatialPoints(cbind(x,y)) # make these an sp object of the points
2006 Jul 04
2
random sampling problems?
Dear friends,
suppose my dataset is the following data:
id<-1:9
x<-c(1,2,3,1,2,3,1,2,3)
y<-c(1,1,1,2,2,2,3,3,3)
data<-data.frame(id,x,y)
id x y
1 1 1 1
2 2 2 1
3 3 3 1
4 4 1 2
5 5 2 2
6 6 3 2
7 7 1 3
8 8 2 3
9 9 3 3
i want to do sampling like this:say the sample size is 3.
First: random sampling from x;
Next ,random sampling from
2008 Jan 26
2
scatterplot3d with categorical data
Dear users,
I'm trying to produce a 3d bar plot but the x and y dimensions have categorical
data -- so I only want 3 points on each axis. So I try:
require(scatterplot3d)
mymat<-data.frame(
x=c(1,1,1,2,2,2,3,3,3),
y=c(1,2,3,1,2,3,1,2,3),
z=c(1,2,3,4,5,6,7,8,9))
scatterplot3d(mymat,
type="h", lwd=5, pch=" ",
xlab="xlabel",
2006 Apr 13
2
a question on subset a dataset
Dear R-users,
I generate a dataset "d", and want to get a subset from it.
**
*z<-rnorm(9)
coords<-cbind(x=c(1,1,1,2,2,2,3,3,3),y=c(1,2,3,1,2,3,1,2,3))
d<-SpatialPointsDataFrame(coords, data.frame (z=z[1:9]))*
The result*/dataset* is
coordinates z
1 (1, 1) 1.41173570
2 (1, 2) 0.18546503
3 (1, 3) -0.04369144
4 (2, 1) -0.21591338
5 (2, 2)
2010 Aug 03
2
Collinearity in Moderated Multiple Regression
Dear all,
I have one dependent variable y and two independent variables x1 and x2
which I would like to use to explain y. x1 and x2 are design factors in an
experiment and are not correlated with each other. For example assume that:
x1 <- rbind(1,1,1,2,2,2,3,3,3)
x2 <- rbind(1,2,3,1,2,3,1,2,3)
cor(x1,x2)
The problem is that I do not only want to analyze the effect of x1 and x2 on
y but
2009 Oct 29
1
singular variance-covariance warning in lmer
Dear R Users,
I was hoping for some help with a recurrent error message in lmer. I am trying to model the effect of temperature on metabolic rate in animals (response = int.length) at different temperatures (mean.sst), with repeated measurements on the same individuals (random effect = female). Ideally I would make a random slope and intercept model where the rate can change differently with
2010 Apr 05
1
strange behavior of matrix
Dear R list,
I have discovered a seemingly peculiar feature when using a matrix to
index itself (yes, this is strange code, which I have now modified to
be more reasonable).
#this makes sense
s <- matrix(1:3,nrow=1)
s[s] #all three elements are shown
#but when I try
s <- matrix(1:2,nrow=1)
s[1] #fine, the first element is shown
s[2] #fine, the second element is
2009 May 29
1
data manipulation involving aggregate
hi all,
I often have a data frame like this example
data.frame(sq=c(1,1,1,2,2,3,3,3,3),area=c(1,2,3,1,2,3,1,2,3),habitat=c("garden","garden","pond","field","garden","river","garden","field","field"))
for each "sq" I have multiple "habitat"s each with an associated "area".
I
2005 Dec 29
1
'last.warning' problem at startup; package Matrix (PR#8453)
On starting an R session, I get the messages:
Fatal errir: unable to restore save data in .RData
Error in fun(...): couldn't find function "assignInNamespace"
Error: .onLoad failed in 'loadNamespace' for 'Matrix'
The only object in my .RData is last.warning, thus:
> last.warning
$"optim or nlminb returned message false convergence (8)"
2005 Dec 12
2
convergence error (lme) which depends on the version of nlme (?)
Dear list members,
the following hlm was constructed:
hlm <- groupedData(laut ~ design | grpzugeh, data = imp.not.I)
the grouped data object is located at and can be downloaded:
www.anicca-vijja.de/lg/hlm_example.Rdata
The following works:
library(nlme)
summary( fitlme <- lme(hlm) )
with output:
...
AIC BIC logLik
425.3768 465.6087 -197.6884
Random effects:
2006 Jan 06
1
lmer p-vales are sometimes too small
This concerns whether p-values from lmer can be trusted. From
simulations, it seems that lmer can produce very small, and probably
spurious, p-values. I realize that lmer is not yet a finished product.
Is it likely that the problem will be fixed in a future release of the
lme4 package?
Using simulated data for a quite standard mixed-model anova (a balanced
two-way design; see code for the
2005 Jul 19
1
Question about creating unique factor labels with the factor function
Hi guys,
I ran into a problem of not being able to create unique labels when creating a factor. Consider an example below:
hb <- factor(c(1,1,1,2,2,2,3,3,3), levels=c(1,2,3),labels=c(1,1,2))
> hb
[1] 1 1 1 1 1 1 2 2 2
Levels: 1 1 2
> unique(hb)
[1] 1 1 2
Levels: 1 1 2
How come there are three unique levels, I thought this would only create one unique level?
>
2012 Jul 20
3
Crosstab with Average and Count
I have the following data:
x <- as.factor(c(1,1,1,2,2,2,3,3,3))
y <- as.factor(c(10,10,10,20,20,20,30,30,30))
z <- c(100,100,NA,200,200,200,300,300,300)
I could create the cross tab of x and y with Sum of z as its elements using
the xtabs function as follows:
# X Vs. Y with Sum Z
xtabs(z ~ x + y)
y
x 10 20 30
1 200 0 0
2 0 600 0
3 0 0 900
How do I replace
2004 Jul 28
6
elegant matrix creation
Hello everybody.
I am trying to reproduce a particular matrix in an elegant way. If I
have
jj1 <-
structure(c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,
3,1,2,3,1,2,3,1,2,3,2,3,1,2,3,1,2,3,1,2,3,
1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,3,1,2,3,1,
2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,
2),.Dim = as.integer(c(9,9)))
[ image(jj1) is good here ] then I can get this with
2009 Aug 19
2
how do i vectorize relational queries in R
I am basically trying to append a value(vector) to one dataframe using a
relational value from another dataframe. Obviously, I can use a loop to
accomplish this. However, is there a way to vectorize it?
Example:
> data <- data.frame(c(1,1,1,2,2,2,3,3,3),rep(2,9)); names(data) <-
> c("Sample","Score")
> meta <-
2004 Jul 22
2
Standard error of a sum
Folks,
This is so simple is driving me crazy. It's not really an R question is
more an Statistics question.
I applied a chemical in 3 different events during a growing season. I
took 3 samples in each event to estimate mean applied chemical.
Thus, I can easily estimate means and st.err by event. I can then
estimate the total chemical applied for the whole season by adding the 3
means
2009 Jul 31
2
merging two data frame with colomns of different length
Dear all,
I am trying to merge two data frames based on a common column but for this
common column both data frame do not have the same length and associated
information. I checked previous exemples in the list but was not able to apply
them in my case... Is someone know how to do that? Below is my code with the
expected result:
# data frame 1
Id1 <- c(1,1,1,2,2,2,3,3,3)
Habit1 <-
2010 Mar 06
2
Plot interaction in multilevel model
I am trying to plot an interaction in a multilevel model. Here is some
sample data. In the following example, it is longitudinal (i.e., repeated
measures), so the outcome, score (at each of the three time points), is
nested within the individual. I am interested in the interaction between
gender and happiness predicting score.
id <- c(1,1,1,2,2,2,3,3,3)
age <-
2023 Oct 24
2
How to Calculate the Mean by Multiple Groups in R
Hello,
I have a data frame with different groups (Time, Target, Conc) and
each entry has a triplicate value of the measurements OD and ODnorm.
How can I merge the triplicates into a single mean value?
I tried the following:
```
df = data.frame(Time=rep(1, 9), Well=paste("A", 1:9, sep=""),
OD=c(666, 815, 815, 702, 739, 795, 657, 705, 663),