Displaying 5 results from an estimated 5 matches for "meanvec".
2004 Nov 08
1
plotting lm coeficients with their means
...l run a linear
model and plot the regression coeficients with their
corresponding means. I am having two problems. I can
get the plot with the function below, but I am having
trouble labeling the points.
function(y,x1,x2,x3,x4){
outlm<-lm(y~x1+x2+x3+x4)
imp<-as.data.frame(outlm$coef[-1])
meanvec<-c(mean(x1),mean(x2),mean(x3),mean(x4))
out<-list(imp,meanvec)
mf<-as.data.frame(out)
plot((mf),xlab="Impact",ylab="performance")
abline(h=mean(meanvec))
abline(v=mean(imp))
}
Problem #2: If I only input x1,x2,and x3 how do I get
the function to ingnore the 4th instea...
2013 Apr 04
5
Help for bootstrapping
...lReturn<-numeric(30/horizon)USReturn<-numeric(30/horizon)for (x in 1: (30/horizon)){ TbillReturn[x]<-prod(data[(12*horizon*(x-1)+1):(12*horizon*(x-1)+12*horizon),col])-1 USReturn[x]<-prod(data[(12*horizon*(x-1)+1):(12*horizon*(x-1)+12*horizon),2])-1}Return<-cbind(TbillReturn,USReturn)MeanVec<-c(mean(TbillReturn),mean(USReturn))VCovMat<-cov(Return)#return(MeanVec, VCovMat)
a<-c(1,1)a<-cbind(a, diag(1,2))
WtVec<-solve.QP(Dmat=VCovMat*2, dvec= MeanVec*lamda,Amat=a,bvec=c(1,0,0),meq=1)
#return(MeanVec, VCovMat, WtVec$solution)return(WtVec$solution)}
#Opt(OriData+1, 1, 5, 0)...
2006 Mar 23
3
Sampling in R
Hi all!
I was wondering if you can help me with a little sampling issue I'm
having in R.
I have a database with 100 observations.
I need to sample n=9 sample size, 200 times (i.e. get 200 samples of
size 9).
N (pop. size) =100
Each sample can't contain the same observation more than one time
(i.e. the program needs to check if the obs. has already been sampled
into the sample -
1998 Oct 16
3
mean and sd of each serial position
...in this example it would have the contents
4.667, 5.667, 5.333333
2. A vector that is the SD at each serial position of a1, a2, and a3.
so in this example it would have the contents
4.041452, 4.041452, 2.081666
Can anyone tell me a good way to do this in R? The only thing I can come
up with is
meanvec<-function(a1,a2,a3)
{
temp<-numeric(3)
for(i in 1:3)
temp[i]<-mean(c(a1[i],a2[i], a3[i]))
return(temp)
}
sdvec<-function(a1,a2,a3)
{
temp<-numeric(3)
for(i in 1:3)
temp[i]<-sd(c(a1[i],a2[i], a3[i]))
return(temp)
}
If this simple-minded approach is the way to go, I wonder how t...
2010 Dec 07
1
Help on loops
...eration.
For example the pseudocode is as follows
##define output matrix
output <- rep(0,n)
## define coefficient vector
b <- c(1,1)
for (i in 1:number of simulations)
{
for (j in 1:id)
{
for(k in 1:t)
{
if(Data$t[,2]==1)
{
meanvec <- Data[k,3:4]%*%b
output[k] = calc (meanvec) # output from calc is a scalar
}
else
output[k]= calc(a*output[k-1]+Data[k,3:4]%*%b)
}
}
}
Thus the end result should be a vector "output" with nine observ...