Displaying 20 results from an estimated 400 matches similar to: "Multivariate regression with constraints"
2008 Aug 04
2
Multivariate Regression with Weights
Hi all,
I'd like to fit a multivariate regression with the variance of the error term porportional to the predictors, like the WLS in the univariate case.
y_1~x_1+x_2
y_2~x_1+x_2
var(y_1)=x_1*sigma_1^2
var(y_2)=x_2*sigma_2^2
cov(y_1,y_2)=sqrt(x_1*x_2)*sigma_12^2
How can I specify this in R? Is there a corresponding function to the univariate specification lm(y~x,weights=x)??
2008 Jul 30
2
Sampling two exponentials
Hi all,
I am going to sample two variables from two exponential distributions, but I want to specify a covariance structure between these two variables. Is there any way to do it in R? Or is there a "Multivariate Exponential" thing corresponding to the multivariate normal? Thanks in advance.
Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
Tel:
2008 Aug 07
4
Switch two rows in a matrix
Hi all,
I have a 4 by 4 matrix, and I want to switch row 2 and row 3 first, then switch column 2 and column 3. Is there an easy way to do it?
The following is a tedious way to get what I want. But I wonder if there is a way to simplify this.
> a=matrix(rnorm(16),4,4)
> a
[,1] [,2] [,3] [,4]
[1,] 0.33833811 -0.9422273 -0.06181611 -1.8346134
[2,] -0.68167996
2008 Aug 07
1
Covariance matrix
Hi all,
Assume I have a random vector with four variables, i.e. A=(a,b,c,d). I am able to get the covariance matrix of vector A, but how can I get the covariance matrix of vector B=(a,c,b,d) by manipulating the corresponding covariance matrix of A? Thanks.
Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
Tel: 609-275-2176
Email:
2008 Jul 25
3
Numerical question
Hi all,
I have n independent variables A_1, A_2, A_3,......,A_n, and each with known variances var(A_1), var(A_2),..., but unknown mean. How can I get the approximation of the variance of the product of the variables using numerical computation, i.e. var(A_1*A_2*A_3*.....*A_n)? Thanks.
Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
Tel: 609-275-2176
2008 Jul 23
1
Questions on weighted least squares
Hi all,
I met with a problem about the weighted least square regression.
1. I simulated a Normal vector (sim1) with mean 425906 and standard deviation 40000.
2. I simulated a second Normal vector with conditional mean b1*sim1, where b1 is just a number I specified, and variance proportional to sim1. Precisely, the standard deviation is sqrt(sim1)*50.
3. Then I run a WLS regression without the
2008 Aug 12
1
VAR question
Hi all,
I got another VAR question here and really appreciate if somebody would help me out :)
I have five time series, say A,B,C,D,E. My objective is to predict the series A using the rest, that is, B, C, D and E. A Vector Autoregression Model should work here. But first of all, I should select which series of B, C, D and E to be include in the VAR model, as well as the number of lags. I wonder
2008 Aug 06
1
Matrix multiplication
Hi all,
Is there an easy way to do cumulative matrix multipliation in R? What's the syntex? Thanks.
Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
Tel: 609-275-2176
Email: yzhang@munichreamerica.com<mailto:yzhang@munichreamerica.com>
[[alternative HTML version deleted]]
2008 Sep 05
1
Plot by column
Dear list,
I have the following matrix. How can I make the following plot?
1. The x-axis has index 1:7, and the first column is plotted against index 1, second against 2, and so on.
2. I want the points from the left upper conner including the antidiagonal to be plotted with col=2, and the rest with col=3
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0.589 0.857 0.923 0.944 0.954 0.963
2011 May 16
4
Problem on glmer
Hi all,
I was trying to fit a Gamma hierarchical model using "glmer", but got weird error message that I could not understand. On the other hand, a similar call to the glmmPQL leads to results that are close to what I expect. I also tried to change tha "nAGQ" argument in "glmer", but it did not solve the problem. The model I was fitting has a simple structure - one
2010 Jan 03
5
update packages from local
Hi all,
I have an old package installed, say "abc". Now I made some changes to the source,
and built a new version of the source code "abc_0.1.1.tar.gz". How can I update the
old package to this newer version from the local tar.gz file? I was running the
following, but it did not work.
setwd("directory where the tar.gz file locates")
2008 Jul 29
1
tensor product of equi-spaced B-splines in the unit square
Dear all,
I need to compute tensor product of B-spline defined over equi-spaced
break-points.
I wrote my own program (it works in a 2-dimensional setting)
library(splines)
# set the break-points
Knots = seq(-1,1,length=10)
# number of splines
M = (length(Knots)-4)^2
# short cut to splineDesign function
bspline = function(x) splineDesign(Knots,x,outer.ok = T)
# bivariate tensor product of
2010 Feb 26
1
need help to resolve RODBC error
I've installed R-2.9.2 (64 bit), unixODBC-2.2.14-p2 (64 bit) and RODBC_1.2-5 (64 bit) on a 64 bit Redhat Linux server (Red Hat Enterprise Linux Server release 5.4 (Tikanga), x86_64) release 2.6.18-164.2.1.el5. I've tested the ODBC drive via isql and the test was success:
[yzhang@ROracleTest ~]$ isql -v DRTST yzhang test
+---------------------------------------+
| Connected!
2010 May 17
2
best polynomial approximation
Dear R-users,
I learned today that there exists an interesting topic in numerical
analysis names "best polynomial approximation" (BSA). Given a function
f the BSA of degree k, say pk, is the polynomial such that
pk=arginf sup(|f-pk|)
Although given some regularity condition of f, pk is unique, pk IS NOT
calculated with least square. A quick google tour show a rich field of
research
2008 Sep 19
2
migrating data from s-plus to R
Dear all,
is there any way to transform a .Data directory created in S-plus 6.1
for windows in a .RData file?
Thanks in advance,
Patrizio Frederic
2008 May 29
2
Troubles plotting lrm output in Design Library
Dear R-helpers,
I'm having a problem in using plot.design in Design Library. Tho
following example code produce the error:
> n <- 1000 # define sample size
> set.seed(17) # so can reproduce the results
> age <- rnorm(n, 50, 10)
> blood.pressure <- rnorm(n, 120, 15)
> cholesterol <- rnorm(n, 200, 25)
> sex <-
2008 Aug 01
2
contour lines in windows device but neither in pdf nor in postscript
library(mvtnorm)
x = seq(-4,4,length=201)
xy = expand.grid(x,x)
sigma = (diag(c(1,1))+1)/2
d2 = matrix(dmvnorm(xy,sigma=sigma),201)
xsamp = rmvnorm(200,sigma=sigma)
contour(x,x,d2)
points(xsamp,col=3,pch=16)
pdf("pdftry.pdf")
contour(x,x,d2)
points(xsamp,col=3,pch=16)
dev.off()
postscript("pstry.ps")
contour(x,x,d2)
points(xsamp,col=3,pch=16)
dev.off()
# I can see
2010 Sep 09
5
Help on simple problem with optim
Dear all,
I ran into problems with the function "optim" when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if anybody would help. The code is in the following and the data is in the attachment.
da <-
2008 Dec 10
4
repeated searching of no-missing values
hi all,
I have a data frame such as:
1 blue 0.3
1 NA 0.4
1 red NA
2 blue NA
2 green NA
2 blue NA
3 red 0.5
3 blue NA
3 NA 1.1
I wish to find the last non-missing value in every 3ple: ie I want a 3
by 3 data.frame such as:
1 red 0.4
2 blue NA
3 blue 1.1
I have written a little script
data = structure(list(V1 = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L
), V2 = structure(c(1L, NA,
2010 Feb 26
1
S4 programming
Dear all,
I'm new to S4 classes and have a question on this. I want to use S4 because I want to define explicitly the slots that the new class can have. But other than that, the new class behaves exactly like a list. But this will not allow me to use the generic functions that are already defined for class "list", such as "$", "c", "[[",