similar to: Weighted descriptives by levels of another variables

Displaying 20 results from an estimated 1000 matches similar to: "Weighted descriptives by levels of another variables"

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
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
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
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,
2010 Aug 12
2
Linear regression on several groups
I have a simple dataset of a numerical dependent Y, a numerical independent X and a categorial variable Z with three levels. I want to do linear regression Y~X for each level of Z. How can I do this in a single command that is without using lm() applied three isolated times? -- View this message in context: http://r.789695.n4.nabble.com/Linear-regression-on-several-groups-tp2322835p2322835.html
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))
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
2006 Oct 05
4
glm with nesting
I just had a manuscript returned with the biggest problem being the analysis. Instead of using principal components in a regression I've been asked to analyze a few variables separately. So that's what I'm doing. I pulled a feather from young birds and we quantified certain aspects of the color of those feathers. Since I often have more than one sample from a nest, I thought I
2005 Feb 02
4
(no subject)
can you recommend a good manual for R that starts with a data set and gives demonstrations on what can be done using R? I downloadedR Langauage definition and An introduction to R but haven't found them overly useful. I'd really like to be able to follow some tutorials using a dataset or many datasets. The datasets I have available on R are Data sets in package 'datasets':
2012 Apr 26
2
Subsetting dataframe with missing values
Dear R-community, I am using R (V 2.14.1) on Windows 7. I have a dataset which consists of 19 variables for 91 individuals or rows. Two of my variables are Age (adult/chick, with no NA values) and Sex (0 for females/1 for females, with quite a few NA values). The sex of many adult birds is unknown (entered as NA in dataframe). At some point of my analyses, I happen to need to need to work with
2018 May 03
4
adding overall constraint in optim()
Hi ? This is giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ? The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim. Mo.vect <-
2006 Aug 21
1
"vcov" error in svyby and svytable functions
Hi, I'm trying to compute survey svytable statistic on subsets by using the svyby function. Here is the code: b<-svyby(~V024+V751, by=~V025, design=strat2, svytable, round=TRUE) The vars, V024, V751 and V025 are factors. The by var has 2 levels, and hence there will be two subsets. strat2 is created by the svydesign function. It's giving me the following error: >
2010 Feb 02
2
Subset and plot
Here is a runable program. When I plot Day and Wgt, it graphs all the data points. All I need is daily.sub1 plotted. I also need each "Tanks" to have its own col or pch. When I run it with the line with pch, it gives me nothing. rm(list=ls()) Trial<-rep(c(1,2),each=12) Tanks=rep(c("a3","a4","c4","h4"),each=3,2) Day=rep(c(1:12),2)
2010 Aug 18
1
svyquantile w/ svyby is returning an error
svymean w/ svyby is working for me... > svyby(~visitcnt, ~agegrp3.f, svymean, design=svydes) agegrp3.f visitcnt se.visitcnt 18-44 18-44 8.755552 0.4953235 45-64 45-64 10.131555 0.5347806 65+ 65+ 9.588802 0.4323629 svyquantile is working for me... > svyquantile(~visitcnt, quantiles=c(.25, .5, .75), ties="rounded", design=svydes) 0.25
2012 Apr 13
2
problem with svyby and NAs (survey package)
Hello I'm trying to get the proportion "true" for dichotomous variable for various subgroups in a survey. This works fine, but obviously doesn't give proportions directly: svytable(~SurvYear+problem.vandal, seh.dsn, round=TRUE) problem.vandal SurvYear FALSE TRUE 1995 8906 786 1997 17164 2494 1998 17890 1921 1999 18322 1669 2001 17623 2122 ...
2018 May 03
2
adding overall constraint in optim()
Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-) > On May 3, 2018, at 3:01 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > > You can't -- at least as I read the docs for ?optim (but I'm pretty > ignorant
2012 Oct 02
2
svyby and make.formula
Hello, Although my R code for the svymean () and svyquantile () functions works fine, I am stuck with the svyby () and make.formula () functions. I got the following error messages. - Error: object of type 'closure' is not subsettable # svyby () - Error in xx[[1]] : subscript out of bounds # make.formula () A reproducible example is appended below. I would appreciate if
2011 Mar 07
1
Risk differences with survey package
I'm trying to use the survey package to calculate a risk difference with confidence interval for binge drinking between sexes. Variables are X_RFBING2 (Yes, No) and SEX. Both are factors. I can get the group prevalences easily enough with result <- svyby(~X_RFBING2, ~SEX, la04.svy, svymean, na.rm = TRUE) and then extract components from the svyby object with SE() and coef() to do the
2018 May 06
1
adding overall constraint in optim()
Hi Michael, A few comments 1. To add the constraint sum(wgt.vect=1) you would use the method of Lagrange multipliers. What this means is that in addition to the w_i (the components of the weight variables) you would add an additional variable, call it lambda. Then you would modify your optim.fun() function to add the term lambda * (sum(wgt.vect - 1) 2. Are you sure that you have defined