Displaying 4 results from an estimated 4 matches for "houseid".
Did you mean:
housed
2012 Apr 03
2
Grouping and/or splitting
I have a dataframe imported from csv file below:
Houseid,Personid,Tripid,taz
1,1,1,4
1,1,2,7
2,1,1,96
2,1,2,4
2,1,3,2
2,2,1,58
There are three groups identified based on the combination of first and
second columns. How do I split this data frame?
I tried
aa <- split(inpfil, inpfil[,1:2])
but it has problems.
Output desired is
aa[1]
Houseid,Person...
2012 Mar 06
1
How to eliminate for next loops in this script
...nly method I could get that worked uses a
series of nested for next loops. I know that there must be a better way to
do so, but could use some assistance pointing the way.
Here is my working, but inefficient script:
library(Hmisc)
rm(list=ls())
load('NHTS.Rdata')
day.wt <- day[c("HOUSEID","WTTRDFIN", "TRIPPURP","TRVLCMIN")]
hh.wt <- hh[c("HOUSEID","WTHHFIN","HHSIZE","HHVEHCNT","HOMETYPE")]
hh.wt$HHBIN <- with(hh.wt,{ cut(HHSIZE,
breaks=c(0,1,2,3,4,max(HHSIZE)),labels=c("1","2&q...
2012 Apr 17
1
random effects using lmer
...a household correlation
and so want to include a household level random effect. I have been using
the lmer command in lme4 package but am getting some strange results that
are completely different to those I get using STATA.
Can I just check that this is the correct code
lmer(IsPos ~ Dist + (1 | HouseID), family=binomial)
Where IsPos is a binary vector of positives and negatives, Dist is the
variable of interest and HouseID is the household ID number.
For those STATA users, the equivalent I'm using is
xtlogit IsPos Dist, i(HouseID)
Any help would be much appreciated..!
Thanks!
Hugh
--
Vi...
2011 Apr 06
5
Need a more efficient way to implement this type of logic in R
I have cobbled together the following logic. It works but is very
slow. I'm sure that there must be a better r-specific way to implement
this kind of thing, but have been unable to find/understand one. Any
help would be appreciated.
hh.sub <- households[c("HOUSEID","HHFAMINC")]
for (indx in 1:length(hh.sub$HOUSEID)) {
if ((hh.sub$HHFAMINC[indx] == '01') | (hh.sub$HHFAMINC[indx] == '02')
| (hh.sub$HHFAMINC[indx] == '03') | (hh.sub$HHFAMINC[indx] == '04') |
(hh.sub$HHFAMINC[indx] == '05'))
hh.sub...