Displaying 17 results from an estimated 17 matches for "tau1".
Did you mean:
tau
2009 Nov 02
1
need help in using Hessian matrix
Hi
I need to find the Hessian matrix for a complicated function from a certain
kind of data but i keep getting this error
Error in f1 - f2 : non-numeric argument to binary operator
the data is given by
U<-runif(n)
Us<-sort(U)
tau1<- 2
F1tau<- pgamma((tau1/theta1),shape,1)
N1<-sum(Us<F1tau)
X1<- Us[1:N1]
Ti<- theta1*qgamma(Us[1:N1],shape,1)
w=N1+1
V<- Us[w:r]
N2<- length(V)
V1<-theta2*qgamma(V,shape,1)
Tj<-V...
2013 Apr 09
0
[R-SIG-Finance] EM algorithm with R manually implemented?
...pi1<-0.5
> pi2<-0.5
> mu1<--0.01
> mu2<-0.01
> sigma1<-0.01
> sigma2<-0.02
> loglik[1]<-0
> loglik[2]<-sum(pi1*(log(pi1)+
> log(dnorm(dat,mu1,sigma1))))+sum(pi2*(log(pi2)+log(dnorm(dat,mu2,sigma2))))
>
>
>
> tau1<-0
> tau2<-0
> k<-1
>
> # loop
> while(abs(loglik[k+1]-loglik[k])>= 0.00001) {
>
> # E step
>
> tau1<-pi1*dnorm(dat,mean=mu1,sd=sigma1)/(pi1*dnorm(x,mean=mu1,sd=sigma1)+pi2*dnorm(dat,mean=mu2,sd=sigma2))
>
> tau2<-pi2*dnorm(dat,...
2012 Aug 01
1
optim() for ordered logit model with parallel regression assumption
...t;, "x2", "x3")
mydta <- readin[myvars]
# remove all missings
mydta <- na.omit(mydta)
# theta is the parameter vector
ologit.lf <- function(theta, y, X) {
n <- nrow(X)
k <- ncol(X)
# b is the coefficient vector for independent variables
b <- theta[1:k]
# tau1 is cut-point 1
tau1 <- theta [k+1]
# tau2 is cut-point 2
tau2 <- theta [k+2]
# tau3 is cut-point 1
tau3 <- theta [k+3]
if (y == 1){
p <- (1/(1+exp( - tau1 + X %*% b)))
}
if (y == 2) {
p <- (1/(1+exp( - tau2 + X %*% b))) - (1/(1+exp( - tau1 + X %*% b)))
}
if (...
2011 Feb 26
0
A problem about realized garch model
...k for my code.
After I simulate data from the model and estimate the data,
I can't get precise estimation for my setting parameters.
This is my simulation code:
=======================
sim<-function(theta)
{
omega = theta[1]
bet = theta[2]
gam = theta[3]
xi = theta[4]
phi = theta[5]
tau1 = theta[6]
tau2 = theta[7]
sigma.u = theta[8]
n = theta[9]
n.warm = 500
n = n+n.warm
z = rnorm(n+1)
u = rnorm((n+1),0,sigma.u)
logh.pre = 1
logx.pre = xi+phi*logh.pre+tau1*z[1]+tau2*(z[1]^2-1)+u[1]
logh = c(logh.pre,rep(0,n))
r = c(rep(0,(n+1)))
logx = c(logx.pre,rep(0,n))
for(i in 2:(...
2012 Jul 11
2
nls problem: singular gradient
Why fails nls with "singular gradient" here?
I post a minimal example on the bottom and would be very
happy if someone could help me.
Kind regards,
###########
# define some constants
smallc <- 0.0001
t <- seq(0,1,0.001)
t0 <- 0.5
tau1 <- 0.02
# generate yy(t)
yy <- 1/2 * ( 1- tanh((t - t0)/smallc) * exp(-t / tau1) ) + rnorm(length(t))*0.01
# show the curve
plot(x=t, y=yy, pch=18)
# prepare data
dd <- data.frame(y=yy, x=t)
nlsfit <- nls(data=dd, y ~ 1/2 * ( 1- tanh((x - ttt)/smallc) * exp(-x / tau2) ), start=...
1998 Apr 27
1
R-beta: vectors in dataframe?
I have a file:
x y z
0.025 0.025 1.65775
0.025 0.050 1.62602
0.025 0.075 1.63683
0.025 0.100 1.91847
0.025 0.125 2.00913
0.025 0.150 1.82222
0.025 0.175 1.70901
0.025 0.200 1.39759
0.025 0.225 1.39089
0.025 0.250 1.04762
If I read the file like this:
data<-read.table("file.dat")
How do I access the vectors x,y,z that are inside the dataframe data? I
studied Venables and
2008 Apr 04
1
Problems with Unit Root testing using ur.df function
...lags:n
if (lags > 1) {
z.diff.lag = x[, 2:lags]
if (type == "none") {
result <- lm(z.diff ~ z.lag.1 - 1 + z.diff.lag)
tau <- coef(summary(result))[1, 3]
teststat <- as.matrix(tau)
colnames(teststat) <- 'tau1'
}
if (type == "drift") {
result <- lm(z.diff ~ z.lag.1 + 1 + z.diff.lag)
tau <- coef(summary(result))[2, 3]
phi1.reg <- lm(z.diff ~ -1 + z.diff.lag)
phi1 <- anova(phi1.reg, result)$F[2]
teststat...
2008 Mar 25
3
derivatives in R
Hi, I posted this message earlier in "Rmetrics" and I don't know whether I
posted in the wrong place, so I'm posting it again in Rhelp.
I have a function in x and y and let's call it f(x,y). I need to get the
Hessian matrix. i.e I need (d^2f/dx^2), (d^2f/dxdy), (d^2f/dydx),
(d^2f/dy^2).I can get these using the D function. now I need to evaluste the
hessian matrix for
2012 Jul 12
0
Generate random numbers with nested Archimedean Copula
...theta1
theta2 x1
x2 x3
I try to follow McNeil (2006)
http://www.ma.hw.ac.uk/~mcneil/ftp/NestedArchimedean.pdf
with R as the programming language. My code so far is as follows:
n = 10000
#parent
tau1 = 0.60
theta1 = (2*tau1)/(1-tau1)
#child
tau2 = 0.80
theta2 = (2*tau2)/(1-tau2)
#parent
V1 = rgamma(n, 1/theta1,1)
#child
V2 = rgamma(n, 1/theta2,1)
u1 = runif(n)
u2 = runif(n)
u3 = runif(n)
u = cbind(u2,u3)
#Create bivariate child copula
u.inner = (1-log(u)/V2)^(-1/theta2)
#Child inner gene...
2009 Nov 01
2
intigrate function and absolute error
Hi
Can we get the result of an intigration without the absolute error?
for example
f1<-function(x1){(1/gamma(alpha))*x1^(alpha-1)*exp(-x1)*log(x1)}
I1<-integrate(f1, 0, (max(cc)-tau1+(theta2/theta1)*tau1)/theta2)
I1
0.08007414 with absolute error < 7.2e-05
I need the answer 0.08007414 withou the other part(with absolute error
<7.2e-05)
how can we do that?
thank you and take care
Laila
[[alternative HTML version deleted]]
2010 Jun 23
1
A question about R2Winbugs
...in=1,bugs.directory="C:/Users/t-wec/Desktop/WinBUGS14",codaPkg=T,debug=T)
mcmcout=read.bugs(model.sim)
summary(mcmcout)
------------------------------------------------------------------------------------------------------------------------
model
{
# cluster parameters mu and tau
tau1 <- (1-a*a)*taue
taue <- 1/sigmae
for (k in 1:K)
{
# cluster mean mu
mu[k,1] ~ dnorm(m,tau1)
for (t in 2:T)
{
mu[k,t] ~ dnorm(meanmu[k,t],taue)
meanmu[k,t] <- m*(1-a)+a*mu[k,t-1]
}
# cluster varicance ta...
2017 Jun 04
0
Hlep in analysis in RWinBugs
...don't know how we perform the analysis. I wonder whether I can run the following the example data and Winbugs Model in R. Your help will be highly appreciated.
Sincerely,
SN PANDIT
===
library(R2WinBUGS)
#Model
model{
#likelihood
for(i in 1:N){
a1[i] ~ dnorm(a11[i],tau)
2[i] ~ dnorm(a21[i],tau1)
a3[i] ~ dnorm(a31[i],tau2)
a11[i]<-sm[i]*S1*m1
a21[i]<-sm[i]*S1*(1-m1)*S2*m2
a31[i]<-sm[i]*S1*(1-m1)*S2*(1-m2)*S3
sum[i]<-a11[i]+a21[i]+a31[i]
}
#priors
#priors are dbeta(0.5,0.5), uniform is dbeta(1,1)
S1~dbeta(1,1)#I(0,0.2) #
S2~dbeta(1,1)#I(0.15,0.5) #
S3~dbeta(1,1)#I(0.3,1)
m1~db...
2017 Jun 04
0
Help in analysis in RWinBugs
...don't know how we perform the analysis. I wonder whether I can run the following the example data and Winbugs Model in R. Your help will be highly appreciated.
Sincerely,
SN PANDIT
===
library(R2WinBUGS)
#Model
model{
#likelihood
for(i in 1:N){
a1[i] ~ dnorm(a11[i],tau)
2[i] ~ dnorm(a21[i],tau1)
a3[i] ~ dnorm(a31[i],tau2)
a11[i]<-sm[i]*S1*m1
a21[i]<-sm[i]*S1*(1-m1)*S2*m2
a31[i]<-sm[i]*S1*(1-m1)*S2*(1-m2)*S3
sum[i]<-a11[i]+a21[i]+a31[i]
}
#priors
#priors are dbeta(0.5,0.5), uniform is dbeta(1,1)
S1~dbeta(1,1)#I(0,0.2) #
S2~dbeta(1,1)#I(0.15,0.5) #
S3~dbeta(1,1)#I(0.3,1)
m1~db...
2010 Aug 02
2
Dealing with a lot of parameters in a function
...MLE.
There will be parameters like mu_i, sigma_i, tau_i, ro_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, tog...
2010 Nov 30
1
confidence interval for logistic joinpoint regression from package ljr
...using forward and backward techniques and see if they are close
2)present the annual percent change (APC) for each of the intervals, ie my present data (1950-2010 in 5 year intervals) is giving me
Variables Coef
b0 Intercept -131.20404630
g0 t 0.06146463
g1 max(t-tau1,0) -0.51582466
g2 max(t-tau2,0) 0.43429615
Joinpoints:
1 tau1= 1990.5
2 tau2= 1995.5
APC 1950->1990=exp(0.06)=1.06-->6%
1990-1995=exp(0.06-0.51)=exp(-0.45)=0.63--> -37%
1995-2010=exp(0.06-0.51+0.43)-->-2%
3) Preferably a confidence interval for the APC should be g...
2009 Feb 21
0
density estimation for d>2 for the DPpackage
...an=c(20,1,110), sigma=sigma)
rnormm<-rbind(rnormm,rnormm2)
#with the following priors
# Prior information
s2<-matrix(c(2,0,0,0,2,0,0,0,2),ncol=3)
m2<-c(5,10,15)
psiinv2<-solve(matrix(c(10000,0,0,0,1,0,0,0,2),ncol=3))
prior<-list(a0=1,b0=1/5,nu1=4,nu2=4,s2=s2,
m2=m2,psiinv2=psiinv2,tau1=0.01,tau2=0.01)
state <- NULL
# MCMC parameters
nburn<-1000
nsave<-5000
nskip<-10
ndisplay<-1000
mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)
# Fit the model
fit3<-DPdensity(y=rnormm,mcmc=mcmc, prior=prior,
state=state,status=TRUE,na.action=na.omit)...
2009 Apr 09
0
Invoking bond_prices function of termstrc package
...'m trying to invoke the function bond_prices from termstrc package.
Here is the code snippet:
library(termstrc)
data(eurobonds)
b <- matrix(rep(c(0,0,0, 1),1),nrow=1,byrow=TRUE)
group<-c("GERMANY")
colnames(b) <- c("beta0","beta1","beta2","tau1")
germaturities<-create_maturities_matrix(eurobonds$GERMANY)
bp<-bond_prices(method =
"Nelson/Siegel",b,germaturities,eurobonds$GERMANY$CASHFLOWS$CF)
bp
Running this, I get the following warning message:
In cf * discount_factors :
longer object length is not a multiple of sh...