Re: [R] Time Series on Binary Data.

2014-03-01 Thread Cristiano Varin
Among various possibilities, you might consider a logistic or probit regression 
model with ARMA errors specified via Gaussian copula. This approach is 
implemented in the package gcmr (Gaussian Copula Marginal Regression).  

Example: logistic model with covariates S1 and S2 and AR(1,2) errors

fit - gcmr( Response ~ S1 + S2 + ... , data = your.data, marginal = 
binomial.marg, cormat = arma.cormat(1,2), options( nrep=1000 ) )

See help(gcmr) for more details. 

Cristiano 
-
Cristiano Varin cristiano.va...@unive.it
Department of Environmental Sciences, 
Informatics and Statistics
Ca' Foscari University of Venice
San Giobbe, Cannaregio 873, 30121 Venezia, Italy 
Tel: +39 0412347439   Fax: +39 0412347444
http://cristianovarin.weebly.com

 Hi,
 
 I have a dichotomous data where some my independent variables are 
 categorical, some are continuous and some are binary(0/1)
 
 My dependent is a binary response (Fail/NoFail,0/1) .
 
 The data is some readings collected everyday over a period of time.
 
 The goal is to use this data and see if we can figure out cause of failure 
 ,the end response.
 
 Example data format
 
 
 Date, Type,Mileage,S1,S2,S3 , Response
 
 03/02/2013,A,32000,1,0,1,.., 1
 
 03/03/2013,B,32400,0,0,0,...,0
 
 03/04/2013,C,45000,0,1,1,..,1
 
 
 Can we do Time series modeling?? Any suggesstions on what type of other 
 exploratory analysis can be used to figure out patterns in data ??
 
 Thanks
 shi
  

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fit Negbin glm model with autoregressive correlation structure

2014-01-31 Thread Cristiano Varin
You may also introduce ARMA errors in negative binomial regression via Gaussian 
copulas. The following webpage illustrates how to use the package gcmr 
(Gaussian Copula Marginal Regression) for fitting negative binomial 
regression model with ARMA(2,1) errors: 

http://cristianovarin.weebly.com/gcmr.html

With best regards,
Cristiano Varin
-
Cristiano Varin cristiano.va...@unive.it
Department of Environmental Sciences, 
Informatics and Statistics
Ca' Foscari University of Venice

http://cristianovarin.weebly.com

Il 31/01/2014 09:41, flavie.v...@vetsuisse.unibe.ch ha scritto:
 Hello,
 I am attempting to estimate the effect of various variables on the 
 time-series of counts of reported cattle stillbirths. We investigate the 
 effect of day-of-week, month, holidays etc...and also the effect of 
 non-temporal variables.
 We performed model comparisons between Gaussian glm, Poisson glm and negbin 
 glm and the latter seems most appropriate for our data.
 We found that the residuals from our best model are not i.i.d. but follow an 
 autoregressive process of order 5 , AR (5). I therefore wish to re-run this 
 model after adding an AR(5) correlation structure in order to get unbiased 
 estimates and standard errors for the variables retained in the model.
 In the past, I have been faced with a similar situation for a Gaussian glm 
 and used the gls function with a corStruct object describing the within-group 
 correlation structure. However, this would not work with our negbin model.
 Looking around on various help forums, I came across the possibilities of 
 using generalized estimating equations instead.
 The gee function (in gee package) has a corstr object which would allow me to 
 specify an AR process of whichever order but there is no option to include a 
 negbin family.
 The geeglm function (in geepack package) does recognized the negbin family 
 but only gives an option to fit an AR(1) correlation structure. The corstr 
 object seems to have a userdefined option but it is unclear how it could be 
 defined for an AR(5) process.
 
 In short, my questions are:
 *is it possible to include an AR (p) correlation structure directly into a 
 negbin glm? How?
 * if GEE are the way forward, how can the the corstr object in geeglm be 
 defined for an AR(p) process?
 
 Thank you for your suggestions,
 
 Dr Flavie Vial
 Veterinary Public Health Institute
 DCR-VPH, Vetsuisse Fakultät
 Schwarzenburgstrasse 155
 CH-3003 Bern
 Switzerland
 
 flavie.v...@vetsuisse.unibe.chmailto:flavie.v...@vetsuisse.unibe.ch
 
 
 
 
 
 
 
   [[alternative HTML version deleted]]
 
 
 
 
 __
 
 R-help@r-project.org
  mailing list
 
 https://stat.ethz.ch/mailman/listinfo/r-help
 
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 
 and provide commented, minimal, self-contained, reproducible code.
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Output of silhouette (cluster package)

2008-06-13 Thread Cristiano Varin
Dear R users,
I am mailing you about the graphical output of silhouette (cluster  
package)

 From the example of silhouette in help(silhouette):

  ar - agnes(ruspini)
  si3 - silhouette(cutree(ar, k = 5), # k = 4 gave the same as pam()  
above
+daisy(ruspini))
  plot(si3, nmax = 80, cex.names = 0.5)

from which one may conclude that group 1 is composed by units from 1  
to 20, group 2 by units from 21 to 43, group 3 by units from 44 to 57,  
group 4 by units from 58 to 60 and, finally, group 5 by units from 61  
to 75.

However, this seems to be in contrast with the output of silhouette  
where the fourth group is composed by units from 46 to 48 instead of  
units from 58 to 60 (belonging to the third cluster), see
  si3
   cluster neighbor   sil_width
  [1,]   15 0.679838078
  [2,]   15 0.745615002
  [3,]   15 0.758796123
  [4,]   14 0.715554768
  [5,]   15 0.664657114
  [6,]   14 0.783993831
  [7,]   12 0.590057470
  [8,]   14 0.747969458
  [9,]   15 0.792304760
[10,]   14 0.803547635
[11,]   14 0.742402051
[12,]   14 0.722302731
[13,]   14 0.665412622
[14,]   15 0.756910666
[15,]   15 0.700685403
[16,]   15 0.743601834
[17,]   15 0.614854124
[18,]   15 0.708007860
[19,]   15 0.700093839
[20,]   14 0.568989067
[21,]   24 0.751866935
[22,]   24 0.790783667
[23,]   24 0.802659788
[24,]   24 0.785895823
[25,]   24 0.822943473
[26,]   24 0.831313347
[27,]   24 0.818043337
[28,]   24 0.805454305
[29,]   24 0.770547118
[30,]   24 0.768289979
[31,]   23 0.794485567
[32,]   24 0.829925955
[33,]   24 0.807379640
[34,]   24 0.790626589
[35,]   24 0.817427927
[36,]   23 0.793572412
[37,]   24 0.760561408
[38,]   24 0.743170109
[39,]   23 0.761413953
[40,]   23 0.704193051
[41,]   24 0.297007126
[42,]   24 0.522049838
[43,]   23 0.488556828
[44,]   34 0.377632488
[45,]   34 0.007214464
[46,]   43 0.699407534
[47,]   43 0.837451212
[48,]   43 0.794349431
[49,]   34 0.632862996
[50,]   34 0.586149139
[51,]   34 0.647326133
[52,]   34 0.650020368
[53,]   34 0.629131005
[54,]   34 0.618843633
[55,]   34 0.586439350
[56,]   34 0.586788051
[57,]   34 0.668108812
[58,]   34 0.650074540
[59,]   34 0.628444500
[60,]   34 0.591393005
[61,]   51 0.770110294
[62,]   51 0.815309198
[63,]   54 0.771622667
[64,]   51 0.806125429
[65,]   51 0.850310507
[66,]   51 0.822984066
[67,]   51 0.852743923
[68,]   51 0.762055943
[69,]   51 0.839180986
[70,]   51 0.854894699
[71,]   51 0.838106473
[72,]   51 0.774812117
[73,]   51 0.795021304
[74,]   51 0.759681469
[75,]   51 0.742553847
attr(,Ordered)
[1] FALSE
attr(,call)
silhouette.default(x = cutree(ar, k = 5), dist = daisy(ruspini))
attr(,class)
[1] silhouette

Thanks for your attention,
Cristiano
-
Cristiano Varin
[EMAIL PROTECTED]
http://www.dst.unive.it/~sammy/









[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.