search for: dmnorm

Displaying 16 results from an estimated 16 matches for "dmnorm".

Did you mean: denorm
2010 Apr 12
1
Strange results from Multivariate Normal Density
Hello, I'm using dmnorm from the package {mnormt} and getting strange results. First, according to the documentation, dmnorm should return a vector of densities, and I'm only getting one value returned (which is what I would expect). I've been interpreting this as the joint density of all values in the x vector (...
2009 Jun 04
1
Using WinBUGS from R: A Multi-Way Array Problem
...3,] 3 6 , , 2 [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 That is, I have copied the orignal data k=2 times. WinBUGS will be supplied the following data d<-list(Yk=Yk, T=T,n=n,k=k). Now in WinBUGS I have to define a multivariate stochastic node as as follows e[i,1:n,kk]~dmnorm( , ) ## i= 1,2,...,T ; kk = 1,2,...,k But Winbugs accepts only something like e[ , , 1:n]~dmnorm( , ). That is "1:n" has to be given at the leftmost position. This means that I need to change the definition of dim indices in R as follows. first index: for kth T by n array sec...
2010 Apr 08
1
a small question about R with Winbugs
...st for dirichlet process for Multivariate normal, but Winbugs always says "expected multivariate node", does that mean I miss something at initialization? I will really appreciate the help to solve this problem Here is the R code, and Winbugs code. model { for(i in 1:N){ y[i,1:2] ~ dmnorm(mu[i,],tau[i,,]) S[i] ~ dcat(pi[]) mu[i,1:2] <- mu.star[S[i],] tau[i,1:2,1:2] <- tau.star[S[i],,]} # Constructive DPP # Stick breaking prior p[1] <- r[1] for (j in 2:C) {p[j] <- r[j]*(1-r[j-1])*p[j-1]/r[j-1]} p.sum <- sum(p[]) for (j in 1:C) {r[j] ~ dbeta(1,alpha); pi[...
2013 Mar 05
2
Error message
...very much in advance. Hanna > integrand <- function(x, rho, a, b, z){ + x1 <- x[1] + x2 <- x[2] + Sigma <- matrix(c(1, rho, rho, 1), 2,2) + mu <- rep(0,2) + f <- pmnorm(c((z-a*x1)/b, (z-a*x2)/b), mu, Sigma)*dmnorm(c(0,0), mu, diag(2)) + f + } > > adaptIntegrate(integrand, lower=rep(-Inf, 2), upper=c(2,2), + rho=0.1, a=0.6, b=0.3, z=3, maxEval=10000) Error in if (any(lower > upper)) stop("lower>upper integration limits") : missing va...
2013 Mar 21
1
"adaptIntegrate" function
...he second integration does not seem to work. Can anyone familiar with this give some help? Thank you with much. Hanna library(mnormt) library(cubature) ff <- function(x, rho){ mu <- rep(0,3) Sigma <-(1-rho)*diag(3)+matrix(rho,3,3) f <- dmnorm(x, mu, Sigma) f } adaptIntegrate(ff, lower=c(-10, -10, -10), upper=c(3,2,1), rho=0.1, maxEval=10000) adaptIntegrate(ff, lower=rep(-Inf, 3), upper=c(3,2,1), rho=0.1, maxEval=10000) [[alternative HTML version deleted]]
2013 Jun 24
0
Running MCMC using R2WinBUGS
...:2,".csv",sep="") > for (i in 1:length(csvs)){ + matrix[[i]]<- read.csv(file=csvs[i],header=TRUE) + print(matrix[[i]]) + } Y1 Y2 1 11 6 2 8 5 3 25 13 4 1 13 5 8 22 Y1 Y2 1 9 1 2 7 9 3 25 13 4 1 18 5 9 12 #Model model { for (j in 1 : Nf) { p1[j, 1:2 ] ~ dmnorm(gamma[1:2], T[1:2 ,1:2]) # T is the precision matrix or inverse sigma for MVN for (i in 1:2) { logit(p[j,i])<-p1[j,i] Y[j,i] ~ dbin(p[j,i],n) } } # Hyper-priors: gamma[1:2] ~ dmnorm(mn[1:2],prec[1:2 ,1:2]) mn<-c(-1.59,-2.44) prec<-structure(.Data = c(.001,0,0,.001),.Dim = c...
2010 Aug 02
2
Dealing with a lot of parameters in a function
...o_i, for i between 1 to 24. Instead of listing all the parameters, one by one in the function definition, is there a neat way to do it in R ? The example is as follows: ll<- function(mu1=-0.5,b=1.2,tau_1=0.5,sigma_1=0.5,ro_1=0.7) { if (tau1>0 && ro<1 && ro>-1) -sum(dmnorm(cbind(x,y),c(mu1,b*mu1),matrix(c(tau_1^2,ro_1*tau_1*sigma_1, ro_1*tau_1*sigma_1,sigma_1^2),nrow=2),log=T)) else NA } but now I need to have the sum of 24 of these negative log-likelihood. Thanks. Yue Notice: This e-mail message, together with any attachme...{{dropped:11}}
2010 Oct 15
1
Problem using BRugs
...76] , y[]) wdy[i]<- inprod(wd[i, 1:676] , y[]) probit(p[i])<- rho_o * woy[i] + rho_d * wdy[i] + rho_w * wwy[i] + beta[1] + beta[2] * cap2[i] + beta[3] * pol2[i] + beta[4] * cap1[i] + beta[5] * pol1[i] + beta[6] * g[i]+ e[i] } # Priors for (j in 1:6) { beta[1:6] ~ dmnorm(mu[1:6], tau[1:6, 1:6]) } rho_o ~ dunif(-1,1) rho_d ~ dunif(-1,1) rho_w ~ dunif(-1,1) for (i in 1:676) { e[i] ~ dnorm(0, 1) } } [[alternative HTML version deleted]]
2008 Jul 23
1
R2WinBUGS problem
...i]+beta[ID[i]]*TBW.cor[i] fit[i] <- mu.dep[i]+CONST[i] } tau.dep <- pow(sigma_dep,-2) sigma_dep ~ dunif(0,100) for (j in 1:16) { alpha[lev[j]] <- AB[lev[j],1] beta[lev[j]] <- AB[lev[j],2] AB[lev[j],1:2] ~ dmnorm(AB.hat[lev[j],],tau.AB[,])I(lower[], upper[]) AB.hat[lev[j],1] <- mu.alpha AB.hat[lev[j],2] <- mu.beta } lower[1] <- 0 lower[2] <- -100 upper[1] <- 100 upper[2] <- 0 mu.alpha ~ dnorm(0...
2006 Oct 09
1
winbugs - R question
...s(data=data, inits=inits, parameters, model.file="c:/try/sur.txt", n.chains = 3, n.iter = 1000, bugs.directory = "c:/Program Files/WinBUGS14/", working.directory = "c:/try", clearWD = FALSE,codaPkg = FALSE,debug=T) model { for (i in 1:n) { Y[i,1:2] ~ dmnorm(mu[i,],P[1:2,1:2]) # means in separate time series mu[i,1] <- inprod(X1[i,],b[,1]) mu[i,2] <- inprod(X2[i,],b[,2]) P[1:2,1:2]<-tau*I[1:2,1:2] } # priors on regression coefficients for (i in 1:2) { for (j in 1:2)...
2012 Jul 09
1
R to winbugs interface
...EVdataBUGS,inits,parameters,"FEVWBModel.txt",n.chains=1,n.iter=60000,n.thin=1,n.burnin=10000) print(FEV.fit,digits=3) attach.bugs(FEV.fit) } The model : model { for (i in 1:n) { FEV[i]~dnorm(mu[i],tau) mu[i]<-beta[1]+beta[2]*Age[i]+beta[3]*Smoke[i]+beta[4]*Age[i]*Smoke[i] } beta[1:r]~dmnorm(beta0[1:r],C0inv[1:r,1:r]) tau~dgamma(a,b) for (i in 1:10) { meanFEVs[i] <- beta[1] + (beta[2]+beta[4])*(i+9) + beta[3] meanFEVns[i] <- beta[1] + beta[2]*(i+9) } FEV20s ~ dnorm(mu20s,tau) FEV20ns ~ dnorm(mu20ns,tau) mu20s <- beta[1] + (beta[2]+beta[4])*20 + beta[3] mu20ns <- be...
2010 Apr 09
0
rjags syntax error
...25]*xi[i,13]+alp[38] mu[i,39]<-lam[26]*xi[i,13]+alp[39] mu[i,40]<-xi[i,14]+alp[40] ## Aca4 mu[i,41]<-lam[27]*xi[i,14]+alp[41] mu[i,42]<-lam[28]*xi[i,14]+alp[42] mu[i,43]<-xi[i,15]+alp[43] ## Work4 mu[i,44]<-lam[29]*xi[i,15]+alp[44] mu[i,45]<-lam[30]*xi[i,15]+alp[45] xi[i,1:45]~dmnorm(u[1:15],phi[1:15,1:15]) } for(j in 1:45){alp[j]~dnorm(0.0, 1.0)} for(j in 1:30){lam[j]~dnorm(0.8,psi[j]} for(j in 1:P){ psi[j]~dgamma(9.0, 4.0) sgm[j]<-1/psi[j] } psd~dgamma(9.0, 4.0) sgd<-1/psd phi[1:3,1:3]~dwish(R[1:3,1:3], 5) phx[1:3,1:3]<-inverse(phi[1:3,1:3]) }
2012 Aug 13
0
rjags error. Error parsing model file:,syntax error on line 5 near ""
...]+xi[i,2] # Factor 2 mu[i,10] <- alpha[10]+lam[10]*xi[i,2] mu[i,11] <- alpha[11]+lam[11]*xi[i,2] mu[i,12] <- alpha[12]+lam[12]*xi[i,2] mu[i,13] <- alpha[13]+lam[13]*xi[i,2]] mu[i,14] <- alpha[14]+lam[14]*xi[i,2] mu[i,15] <- alpha[15]+lam[15]*xi[i,2] xi[i,1:2] ~ dmnorm(u[1:2],phi[1:2,1:2]) } for (j in 1:nIndicators) { alpha[j] ~ dnorm(0.0, 1.0) } #--------------------------------------- # Distributions and Priors #Priors on Loadings lam[2] ~ dnorm(0,psi[2]) lam[3] ~ dnorm(0,psi[3]) lam[4] ~ dnorm(0,psi[4]) lam[5] ~ dnorm(0,psi[5]) lam[6] ~ dnorm(0,psi[6]) lam...
2012 Jul 27
3
bivariate normal
Dear list members I need a function that calculates the bivariate normal distribution for each observation. It is part of a likelihood function and I have 1000's of cases. As I understand it I cannot use packages like "mvtnorm" because it requres a covariance matrix of the same dimension as the number of observations. Basically what I need is a function that takes as arguments a
2011 Jun 23
0
Fwd: Re: Help with winbugs code
...,24]<-lam[16]*eta[i,3] mu[i,25]<-lam[17]*eta[i,3] #faktor Persepsi Niat untuk Menggunakan mu[i,26]<-eta[i,4] mu[i,27]<-lam[18]*eta[i,4] mu[i,28]<-lam[19]*eta[i,4] #faktor Adopsi E-government mu[i,29]<-eta[i,5] mu[i,30]<-lam[20]*eta[i,5] #model persamaan struktural xi[i,1:5] ~dmnorm(u[1:5],phi[1:5,1:5]) eta[i,1]~dnorm(nu[i,1],pskp) nu[i,1]<-gam[1]*xi[i,2]+gam[2]*xi[i,3]+gam[3]*xi[i,4] dthat[i,1]<-eta[i,1]-nu[i,1] eta[i,2]~dnorm(nu[i,2],pspk) nu[i,2]<-gam[4]*xi[i,1]+beta[1]*eta[i,1] dthat[i,2]<-eta[i,2]-nu[i,2] eta[i,3]~dnorm(nu[i,3],pssp) nu[i,3]<-beta[2]*et...
2017 Aug 17
2
How to install Tidyverse on Ubuntu 17.04? Getting gcc errors for -fstack-protector-strong and -Wdate-time
...installation of package ?colorspace? had non-zero exit status * installing *source* package ?psych? ... ** package ?psych? successfully unpacked and MD5 sums checked ** R ** data *** moving datasets to lazyload DB ** inst ** preparing package for lazy loading Error : objects ?rmnorm?, ?sadmvn?, ?dmnorm? are not exported by 'namespace:mnormt' ERROR: lazy loading failed for package ?psych? * removing ?/home/popx/R/x86_64-pc-linux-gnu-library/3.4/psych? Warning in install.packages : installation of package ?psych? had non-zero exit status * installing *source* package ?Rcpp? ... ** package...