Displaying 20 results from an estimated 59 matches for "wtd".
Did you mean:
ltd
2006 Mar 16
4
problem for wtd.quantile()
Dear R-users,
I don't know if there is a problem in wtd.quantile (from library "Hmisc"):
--------------------------------
x <- c(1,2,3,4,5)
w <- c(0.5,0.4,0.3,0.2,0.1)
wtd.quantile(x,weights=w)
-------------------------------
The output is:
0% 25% 50% 75% 100%
3.00 3.25 3.50 3.75 4.00
The version of R I am using is: 2.1.0
Best,Ji...
2010 Mar 20
2
different forms of nls recommendations
...:
http://n4.nabble.com/file/n1676330/US_Final_Values.txt US_Final_Values.txt
and the following code i got the image at the end of this message:
US.final.values<-read.table("c:/tmp/US_Final_Values.txt",header=T,sep=" ")
US.nls.1<-nls(US.final.values$ECe~a*US.final.values$WTD^b+c,data=US.final.values,start=list(a=2.75,b=-0.95,c=0.731),trace=TRUE)
f.US1<-function(x){coef(US.nls.1)["a"]*x^coef(US.nls.1)["b"]+coef(US.nls.1)["c"]}
xvals.US1<-seq(min(US.final.values$WTD),max(US.final.values$WTD),length.out=75)
yvals.US1<-f.US1(xvals.US1...
2007 May 31
3
Problem with Weighted Variance in Hmisc
The function wtd.var(x,w) in Hmisc calculates the weighted variance of x
where w are the weights. It appears to me that wtd.var(x,w) = var(x) if all
of the weights are equal, but this does not appear to be the case. Can
someone point out to me where I am going wrong here? Thanks.
Tom La Bone
[[alternative...
2011 Apr 20
2
survexp with weights
....00085 -2.00130 0.0450
Likelihood ratio test=164 on 5 df, p=0 n= 308, number of events=
143
(110 observations deleted due to missingness)
>
> plot(survfit(Surv(time, status>0) ~ trt, data=pbc))
> lines(survexp( ~ trt, ratetable=pfit, data=pbc), col='purple')
>
> pfit.wtd <- coxph(Surv(time,status>0) ~ trt + log(bili) + log(protime) + age +
+ + platelet, weights=albumin, data=pbc
+ )
>
> pfit.wtd
Call:
coxph(formula = Surv(time, status > 0) ~ trt + log(bili) +
log(protime) +
age + +platelet, data = pbc, weights = albumin)...
2009 Jun 23
3
subset POSIXct
...dt tf
1 2009-06-20 00:53:00 73
2 2009-06-20 01:08:00 73
3 2009-06-20 01:44:00 72
4 2009-06-20 01:53:00 71
5 2009-06-20 02:07:00 72
...
I need a subset of the rows where the minutes are 53. The hour is
immaterial. I can not find a wildcard character to use to select the
rows.
as.character(wtd$dt) %in% "2009-06-21 ??:53:00" or as.character(wtd
$dt) %in% "2009-06-21 **:53:00" does not work.
What would you recommend?
Thanks,
Keith Jones, Ph.D.
VTS Pumps
2004 Oct 21
0
Hmisc: Using stratified weighted means (wtd.mean) within a function
...NaN NaN 6.8 7.1
9 7.6 7.9 7.6 7.1 7.2 NaN NaN 7.9 8.6 7.7 NaN 7.9 NaN 7.2 7.1
10 8.2 8.2 8.1 8.0 7.5 NaN NaN 8.2 NaN 7.5 NaN NaN NaN 7.5 7.0 etc.
For my current situation, I need to have this function use a weighted mean and I am trying to incorporate the 'wtd.mean' function from Hmisc. I have tried various scenarios relying on the documentation for 'wtd.mean' in the Hmisc (shown below), but to no avail. Any assistance would be much appreciated.
set.seed(1)
x <- runif(500)
wts <- sample(1:6, 500, TRUE)
xg <- cut2(x,g=4)
# Here is...
2012 Jul 24
1
Function for ddply
...rite functions. I
know I'm out of my depth posting here, and I'm sure my issue is mundane.
But here goes. I'm analyzing the American National Election Study (nes),
looking at mean values of a numeric dep_var (environ.therm) across values
of a factor (partyid3). I use ddply from plyr and wtd.mean from Hmisc. The
nes requires a weight var (wt). I use Rcmdr's plotMeans to obtain a line
chart. The following code works:
attach(nes)
obj1 = ddply(nes, .(partyid3), summarise,
var = wtd.mean(environ.therm, wt))
print(obj1)
plotMeans(obj1$var, obj1$partyid3, error.bars="none")...
2012 Apr 20
1
pasting a formula string with double quotes in it
...nsert
double quotes around the strings. Here's an example:
location <- c("AL", "AK", "MA", "PA")
v=2
test <- cbind(
" <- cbind(df$DATE[df$LOCATION %in% c(",
location[v],
")], df$WTD.AVG.PRICE[df$LOCATION %in% c(",
location[v],
")])")
test <- paste(test, collapse="")
test
Solution:
[1] " <- cbind(df$DATE[df$LOCATION %in% c(AK)], df$WTD.AVG.PRICE[df$LOCATION
%in% c(AK)])"
This does not pr...
2008 Jan 07
2
How should I improve the following R code?
...period:
library(Hmisc)
stbl <- read.csv("data.csv")
index <- lapply(strsplit(stbl$index, ":", fixed = TRUE), as.numeric)
count <- lapply(strsplit(stbl$count, ":", fixed = TRUE), as.numeric)
len <- length(index)
for (i in 1:len) {
v <- wtd.quantile(index[[i]], count[[i]], c(0, 0.2, 0.5, 0.8, 1))
stbl$q0[i] <- v[1]
stbl$q2[i] <- v[2]
stbl$q5[i] <- v[3]
stbl$q8[i] <- v[4]
stbl$q10[i] <- v[5]
}
It works fine for a small N, but it get quickly inefficient as N grows. The
for-loop takes too long. How...
2010 Dec 30
2
optim and singularity
...t? Any clues would be very
helpful in moving forward. The overall goal of the code below is to
minimize the residuals between the blue circles and green squares by
adjusting the limits of the secondary y-axis.
Thanks, Eric
library(zoo)
temp.dat<-read.table(textConnection("Well Meas_Date WTD ECgw GW_Project_Area
Region Avg.EM.Survey.Value Avg.Soil.Paste.EC SD_EM_Survey
1 4/12/1999 1.75 2.27 LOWER-UPSTREAM US NA NA NA
1 5/11/1999 1.24 5.04 LOWER-UPSTREAM US NA NA NA
1 5/27/1999 1.27 4.45 LOWER-UPSTREAM US NA NA NA
1 6/3/1999 1.27 4.09 LOWER-UPSTREAM US 3.347069 3.126667 0.6347013
1 6/11...
2007 Jul 23
1
replacing double for loops with apply's
Hi,
I am doing double for loops to calculate SDs with some weights and wondering
if I can get rid of the outer for loop as well. I made a simple examples
which is essentially what I am doing.
Thanks for your help!
-Young
#------------------------------------------------------
# wtd.var is Hmisc package
# you can replace the 3 lines inside for loop as
# sdx[i,] = apply(x[(i-4):i,],2,var,na.rm=T)
# -------------------------------------------------------
x = matrix(rnorm(200),10,20)
sdx = matrix(0,10,20)
for(i in 5:nrow(x)){
wts = ( 0.5 )^(i-c(1:i))...
2007 Oct 05
0
Extracting df (degree of freedom) & estfun (estimating function) from model built in lmer or lmer2
Hello R-users:
Could you please tell me how can I extract the "df (degree of freedom)" and "estfun (estimating functions)" for the following lmer (or lmer2) model?
wtd.mixed<-lmer(ddimer~race+steroid+psi+sofa+apache + (1|subject), method="ML", data=final, cluster="id", weights=w)
I tried the following codes:
- for the degree of freedom (erorr message in the red):
>so <- summary(wtd.mixed)
> so$df[1:6]
NULL
Warning message:
$...
2009 Jan 19
1
conditional weighted quintiles
...only weighted quintiles; but what
I need is conditional weighted quintiles. The below example illustrates
what I mean.
x <- data.frame("id"=c(1:5),"income"=c(10,10,20,30,50),
"education"=c(0,5,5,0,0),"weight"=c(3,2,3,1,1))
x
library(Hmisc)
wtd.quantile(x$income,weights=x$weight)
wtd.quantile(x$education,weights=x$weight)
I would like to see the expenditure of each quintile conditional on income, i.e.
the education expenditures of the 5th quintile equal to zero.
Thanks in advance,
--
ozan bakis
--__--__--
2007 Jul 19
0
[LLVMdev] memory hog llvm-ld
Hi Holger,
> Note that I did specify "-g", but not any "-Ox" switches. That
> made the size of all *.o files together being 143 MB.
LLVM represents debug info as explicit calls to intrinsics.
This approach has many advantages, but a possible disadvantage
is that it can significantly increase the size of the bitcode.
I don't know if that explains your observations.
2010 Dec 22
0
adjust secondary y-axis bounds to minimize visual residuals
...stuff the code that follows the plot
commands into a loop that adjusts ylim_2 so as to minimize "min_this"? I'm
guessing there is a function to do this?
Thanks,
Eric
library(zoo)
#example data and plotting commands follow
temp.dat<-read.table(textConnection("Well Meas_Date WTD ECgw GW_Project_Area
Region Avg.EM.Survey.Value Avg.Soil.Paste.EC SD_EM_Survey
1 4/12/1999 1.75 2.27 LOWER-UPSTREAM US NA NA NA
1 5/11/1999 1.24 5.04 LOWER-UPSTREAM US NA NA NA
1 5/27/1999 1.27 4.45 LOWER-UPSTREAM US NA NA NA
1 6/3/1999 1.27 4.09 LOWER-UPSTREAM US 3.347069 3.126667 0.6347013
1 6/11...
2007 Jul 19
2
[LLVMdev] memory hog llvm-ld
...advantages, but a possible disadvantage
> is that it can significantly increase the size of the bitcode.
> I don't know if that explains your observations. I'm curious
> to know how gcc stores debug info...
GCC stores debug info in ELF sections of the .o file, e.g.:
$ objdump -h wtd.o
wtd.o: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000ef4 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 00000000 00000000 00000f28 2**2...
2006 Jan 12
2
tapply and weighted means
I' m trying to compute weighted mean on different
groups but it only returns NA. If I use the following
data.frame truc:
x y w
1 1 1
1 2 2
1 3 1
1 4 2
0 2 1
0 3 2
0 4 1
0 5 1
where x is a factor, and then use the command :
tapply(truc$y,list(truc$x),wtd.mean, weights=truc$w)
I just get NA. What's the problem ? What can I do ?
2012 Mar 06
1
How to eliminate for next loops in this script
...p;
trips$DUTYPE == hom & trips$PURPOSE == pur,
select=c("HOUSEID","WTTRDFIN", "WTHHFIN"))
cat(length(tmp$HOUSEID))
cat(",")
tmp$tr <- (tmp$WTTRDFIN/365)/tmp$WTHHFIN
w.m <- wtd.mean(tmp$tr,weights=tmp$WTHHFIN)
w.sd <- sqrt(wtd.var(tmp$tr, weights=tmp$WTHHFIN))
cat(w.m)
cat(",")
cat(w.sd)
cat("\n")
}
sink()
[[alternative HTML version deleted]]
2017 Nov 24
2
number to volume weighted distribution
Hi Duncan
I tried Ecdf and/or wtd.quantile from Hmisc and it is working (probably).
Ecdf(x, q=.5)
Ecdf(x, weights=xw,col=2, add=T, q=.5)
wtd.quantile(x)
0% 25% 50% 75% 100%
10 10 10 100 300
wtd.quantile(x, weights=xw, type="i/n")
0% 25% 50% 75% 100%
10.0000 138.8667 192.5778 246.2889...
2012 Nov 21
1
update fit (removing insignificant variables)
...???????? 1.436647351? 0.2540660? 5.65462216 0.02988003
#X5?????????? -0.005406684? 0.2906822 -0.01859998 0.98684896
#X6?????????? -0.050101169? 0.1486149 -0.33712071 0.76811703
#X7??????????? 0.563284987? 0.1204945? 4.67477901 0.04284010
#X8?????????? -1.901918462? 0.2697166 -7.05154460 0.01952387
Wtd<-row.names(res[res[,"Pr(>|t|)"]<0.05,])
?Wtd1<-Wtd[!grepl("\\(.*\\)",Wtd)]
fit1<-lm(as.formula(paste("Y~",paste(Wtd1,collapse="+"))),data=dat1)
?coef(summary(fit1))
#?????????????? Estimate? Std. Error?? t value???? Pr(>|t|)
#(Intercept) 146...