Displaying 20 results from an estimated 4000 matches similar to: "Linear regression on several groups"
2012 Jun 06
2
Main effects and interactions in mixed linear models
Dear all,
This question may be too basic quesition for this list, but if someone has
time to answer I will be happy. I have tried to find out, but haven't found
a consice answer.
As an example I use "Pinheiro, J. C. & Bates, D. M. 2000. Mixed-effects
models in S and S-PLUS. Springer, New York." page 225, where rats are fed
by 3 different diets over time, which body mass has
2009 Jul 06
2
ReShape chicks example - line plots
Hi,
In the examples from the ReShape package there is a simple example
of using melt followed by cast that produces a smallish amount of
output about the chicks database. Here's the code:
library(reshape)
names(ChickWeight) <- tolower(names(ChickWeight))
chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE)
DietResults <- cast(chick_m, diet + chick ~ time)
DietResults
My challenge
2010 Oct 01
2
Format of Output of Residuals
An excerpt from dataset ChickWeight:
??? weight Time Chick Diet
1?????? 42??? 0???? 1??? 1
2?????? 51??? 2???? 1??? 1
3?????? 59??? 4???? 1??? 1
I am interested in the residuals of the dataset.? Specifically in
saving them to another format. I have been creating text files with
sink.
CW.lm <- lm(weight ~ Diet, ChickWeight)
resid.CW.lm <- resid(CW.lm)
But when I call:
resid.CW.lm
The data
2009 Nov 14
4
Weighted descriptives by levels of another variables
I've noticed that R has a number of very useful functions for
obtaining descriptive statistics on groups of variables, including
summary {stats}, describe {Hmisc}, and describe {psych}, but none that
I have found is able to provided weighted descriptives of subsets of a
data set (ex. descriptives for both males and females for age, where
accurate results require use of sampling
2008 Jul 30
1
bug in 'margins' behavior in reshape - cast
according to the documentation of the cast function in the reshape function,
I would expect this bit of code from the examples to calculate marginal
means over only the 'diet' variable.
#Chick weight example
names(ChickWeight) <- tolower(names(ChickWeight))
chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE)
cast(chick_m, diet + chick ~ time, mean, margins="diet")
But,
2015 Apr 30
2
predict nlme
Estimado Oliver Nuñez
Envío un ejemplo reproducible.
Javier Marcuzzi
# de donde tomo datos, y tiene el modelo (en el pdf)
library(MCMCglmm)
# librería con las funciónes que voy a usar
library(nlme)
datos0<-ChickWeight
# creo algunos datos que agrego a los origonales
Factor<-as.numeric(datos0$Chick)
Factor[Factor > 0 & Factor <= 10] <- 'A'
Factor[Factor > 10
2011 Mar 01
1
Distintos soft
Les consulto por lo siguiente:
Se me ocurrió usar datos de MCMCglmm en otros procedimientos de R, comparar
los resultados y el tiempo como facilidad de uso, para lo cual use LME4, los
resultados fueron parecidos, entendiendo que internamente los algoritmos
tienen diferencias, es lógico que los resultados no coincidan exactamente,
pero aproximadamente tienen que ser compatibles, en este caso
2015 Apr 30
2
predict nlme
Estimados
Tengo un error que me desconcierta, es un código que simplifiqué de otro trabajo donde no hay problemas, sin embargo me da un error.
Una diferencia es que en mi otro trabajo uso spline y ahora polinomio, este es de segundo grado y se encuentra tanto en efectos fijos como aleatorios, el modelo es correcto, corre con MCMCglmm pero no con nlme.
grid <- expand.grid(Tiempo=4:6,
2006 Mar 13
2
Error Message from Variogram.lme Example
When I try to run the example from Variogram with an lme object, I get
an error (although summary works):
R : Copyright 2005, The R Foundation for Statistical Computing
Version 2.2.1 (2005-12-20 r36812)
ISBN 3-900051-07-0
...
> fm1 <- lme(weight ~ Time * Diet, BodyWeight, ~ Time | Rat)
Error: couldn't find function "lme"
> Variogram(fm1, form = ~ Time | Rat, nint =
2010 Aug 18
4
Using objectname in function
Is there anyway I can convert a vectors objectname to a string to be used in
fx:
Monkey<-c(0,0,0,1,1,1)
Wax<-c(1,0,1,0,1,0)
f<-function(x,y){ table(x,y) }
f(Monkey,Wax)
so that the printout is not
y
x 0 1
0 1 2
1 2 1
but
Wax
Monkey 0 1
0 1 2
1 2 1
--
View this message in context:
2012 Apr 12
1
Using dcast with multiple functions to aggregate
Dear R communitiy,
I am trying to use multiple functions for aggregation within a function
call for dcast. However this seems to result in an error. Also I have not
managed to make dcast() work with fun.aggregate=sd. Please find attached
some example code using the ChickWeight data.
Many thanks for your help!
Jokel
#Chick weight example
names(ChickWeight) <- tolower(names(ChickWeight))
2008 Jan 22
1
anova function to test the difference between two coefficients in nlme package
Dear Dr. Bates, and R-help,
I've tried the anova function to test the difference between two
coefficients, as shown on page 225 of your book "Mixed Effects Models
in S and S-Plus (Statistics and Computing)".
When I type: anova( fm2BW.lme, L = c(TimeDiet2 = 1, TimeDiet3 = -1) )
I got the following error message:
Error: unexpected '=' in "anova( fm2BW.lme, L =
2011 Mar 01
2
Entering table with multiple columns & rows
Hi,
I'm having difficulty with getting a table to show with
multiple rows and columns. Below is the commands that I've typed in and
errors that I am getting. Thank you.
Laura
Table trying to enter:
Diet: Binger-yes: Binger-No: Total:
None 24 134 158
Healthy 9 52 61
Unhealthy 23 72 95
Dangerous 12 15 27
>
2015 Oct 27
2
pregunta
Otras variantes con y sin paquetes adicionales...
> sapply(split(datIn$Gain, as.factor(datIn$Diet)), mean)
d1 d2 d3
280 278 312
> by(datIn$Gain, datIn$Diet, mean)
datIn$Diet: d1
[1] 280
--------------------------------------------------------------
datIn$Diet: d2
[1] 278
--------------------------------------------------------------
datIn$Diet: d3
[1] 312
>
> library(dplyr)
>
2015 Oct 28
2
pregunta
Me gusta la respuesta uqe has dado, pero si por ejemplo, alguno de los datos tiene datos faltantes, entonces devuelve NA.
He probado con:
sapply(split(datos$uno, as.factor(datos$dos)), mean(na.rm=TRUE))
pero da fallo.
¿Cómo se podría hacer para que devolviera además la media obviando los NA y que contara el numero de NA por categoria?
> Date: Wed, 28 Oct 2015 00:13:45 +0100
> From: cof
2015 Oct 27
3
pregunta
Estimados
Cuando existia epicalc, había una manera muy fácil de determinar la media de una variable (en esta caso Gain) por grupos, en este caso (Diet). ?Como se puede hacer ahora?
Diet Gain
1 d1 270
2 d1 300
3 d1 280
4 d1 280
5 d1 270
6 d2 290
7 d2 250
8 d2 280
9 d2 290
10 d2 280
11 d3 290
12 d3 340
13 d3 330
14 d3 300
15 d3 300
2013 Apr 20
7
Reshape or Plyr?
H all,
I have relative abundance data from >100 sites. This is from acoustic
monitoring and usually the data is for 2-3 nights but in some cases my
be longer like months or years for each location..
The data output from my management data base is proved by species by
night for each location so data frame would look like this below. What I
need to do is sum the Survey_time by Spec_Code for
2012 Sep 28
2
changing outlier shapes of boxplots using lattice
Hello
This is Elaine.
I am using package lattice to generate boxplots.
Using Richard's code, the display was almost perfect except the outlier
shape.
Based on the following code, the outliers are vertical lines.
However, I want the outliers to be empty circles.
Please kindly help how to modify the code to change the outlier shapes.
Thank you.
code
package (lattice)
dataN <-
2018 May 04
2
Regression model fitting
Hi all ,
I have a dataframe (Hypertension) with following headers :-
> Hypertension
ID Hypertension(before drug A) Hypertension(On drug A) On drug B? Healthy diet?
1 160 90 True True
2 190
2013 Jan 12
1
panel failure in xyplot
Hello
I ran the code below but it said:
no object "'panel.xyplot.intermediate.hh'"
Please kindly advise how to modify the code.
thank you.
(It works with panel.bwplot.intermediate.hh)
Elaine
code
library(HH)
# data input
dataN <-read.csv("H:/R_data/Mig_bird_586.csv",header=T, row.names=1)
dim(dataN)
dataN[1,]
str(dataN)
diet.code <-