[R] Estimating bivariate normal density with constrains

2011-10-19 Thread Serguei Kaniovski
) I have looked at several packages, including Gaussian mixture models in Mclust, but I am not sure what is the best way, or the best package to use for this task. Greatly appreciate any suggestions! Serguei Kaniovski Austrian Institute of Economic

Re: [R] Accessing variables in a data frame

2011-06-27 Thread Serguei Kaniovski
Thanks! I did not realize you can access variables by name like this. Serguei __ 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

[R] Accessing variables in a data frame

2011-06-26 Thread Serguei Kaniovski
, for example to compute gdp_w - gdp_i inf_w - inf_i unp_w - unp_i or gdp - gdp_w inf - inf_w unp - unp_w without needing to code each difference separately? Thanks for your help! Serguei Kaniovski [[alternative HTML version deleted]] __ R-help@r

[R] Canonical link for the GLM gamma model

2009-08-19 Thread Serguei Kaniovski
Hello! When I estimate a glm gamma model using the canonical link (inverse), I get the opposite signs on almost all coefficients compared to the same model (i.e. with the same linear predictor) estimated using other suitable links (log, logit). What confuses me is that most of sources quote

[R] Help on a combinatorial task (lists?)

2009-08-11 Thread Serguei Kaniovski
” equally often. Can you help? Thanks a lot! Serguei Kaniovski __ 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

Re: [R] Help on a combinatorial task (lists?)

2009-08-11 Thread Serguei Kaniovski
this happens, as tabulate does not work on lists. The answer, of course, should be that equal weights are “decisive” equally often. Can you help? Thanks a lot! Serguei Kaniovski __ R-help@r-project.org mailing list https://stat.ethz.ch

[R] Problem with contrast

2009-07-29 Thread Serguei Kaniovski
Hello All, I am trying to estimate a generalized linear model using a single dummy variable (bilat). I want to use contr.sum, in which (please correct me if I am wrong) the implicit coefficient on the contrast equals the negative of the sum of all estimated coefficients. I cannot get the

Re: [R] Compute correlation matrix for panel data with specific ordering

2009-06-29 Thread Serguei Kaniovski
I apologize for not being specific enough in my previous posting. Assume you have panel data in the form: df - data.frame( cbind( rep( c( AUT , BEL , DEN , GER ) , 4) , cbind( rep( c( 1999 , 2000 , 2001 , 2002 ) , 4 ) ), sample( 10 , 16 , replace=T) ) ) names(df) - c( country , year , x )

Re: [R] Compute correlation matrix for panel data with, specific ordering

2009-06-28 Thread Serguei Kaniovski
Ok I see how to sort the factors, but how do I compute the correlation matrix in a repeated observations dataset (see the first part of my question) Thanks again for your help! Serge __ R-help@r-project.org mailing list

[R] Compute correlation matrix for panel data with specific ordering

2009-06-27 Thread Serguei Kaniovski
in the variable x in such a way that the rows columns of the resulting correlation matrix are not in an alphabetical order but in the order of a given factor vector - here SORT. How can I do this? Greatly appreciate any help! Serguei Kaniovski __ R-help@r

[R] Constrained corr matrix closest to a given corr matrix

2009-06-26 Thread Serguei Kaniovski
this can be accomplished with Lagrange multipliers and an optimization routine. Thanks a lot! Serguei Kaniovski __ 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

[R] Linear constraints for constrasts

2009-05-20 Thread Serguei Kaniovski
the value of 1 when the country is in the pair and 0 otherwise, i.e. “Bilat”, “d_GER”, “d_USA”, “d_JAP” GER_USA, 1, 1, 0 GER_JAP, 1, 0, 1 USA_JAP, 0, 1, 1 These contrasts highlight the effect of having a given country in the pair. Thank you for your help! Serguei Kaniovski

[R] Dummy (factor) based on a pair of variables

2009-04-18 Thread Serguei Kaniovski
Dear All! my data is on pairs of countries, i and j, e.g.: y,i,j 1,AUT,BEL 2,AUT,GER 3,BEL,GER I would like to create a dummy (indicator) variable for use in regression (using factor?), such that it takes the value of 1 if the country is in the pair (i.e. EITHER an i-country OR an j-country).

Re: [R] Dummy (factor) based on a pair of variables

2009-04-18 Thread Serguei Kaniovski
Bernardo: this is not quite what I am looking for, Let the data be: y,i,j 1,AUT,BEL 2,AUT,GER 3,BEL,GER then the dummies sould look like: y,i,j,d_AUT,d_BEL,d_GER 1,AUT,BEL,1,1,0 2,AUT,GER,1,0,1 3,BEL,GER,0,1,1 I can generate the above dummies but can this design be imputed in a reg. model

[R] Implementing a linear restriction in lm()

2008-12-24 Thread Serguei Kaniovski
Dear All! I want to test a coeffcient restriction beta=1 in a univariate model lm (y~x). Entering lm((y-x)~1) does not help since anova test requires the same dependent variable. What is the right way to proceed? Thank you for your help and marry xmas, Serguei Kaniovski

Re: [R] Vertex enumeration and center of mass for convex polytops

2008-10-08 Thread Serguei Kaniovski
Kaniovski [EMAIL PROTECTED] wrote: From: Serguei Kaniovski [EMAIL PROTECTED] Subject: [R] Vertex enumeration and center of mass for convex polytops To: [EMAIL PROTECTED] Received: Wednesday, 1 October, 2008, 10:00 PM Dear All! I am looking for a package that contains routines for vertex

[R] Vertex enumeration and center of mass for convex polytops

2008-10-01 Thread Serguei Kaniovski
Dear All! I am looking for a package that contains routines for vertex enumeration and center of mass computation for convex polytops. Thanks in advance, Serguei Kaniovski __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

[R] Fitdistr of a 3 parameter Gamma distribution

2008-06-24 Thread Serguei Kaniovski
Hello, how can I fit a three, as opposed to a two parameter Gamma distribution, i.e. one in which shape and rate are not tied. Thanks, Serguei __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] Kappa distribution

2008-05-29 Thread Serguei Kaniovski
Hallo all, I am looking for an R implementation of the four parameter kappa distribution (cdf, pdf, quantile, and ransom numbers), or at a minimum, the generalized logistic distribution. Any suggestions? Thank you very much, Serguei __

[R] Help with factors

2008-05-14 Thread Serguei Kaniovski
Hallo All, I have difficulties understanding how factors work in R. Suppose a have data in the panel form below. I would to compute a correlation coefficient (actually apply a different function of two time series) in the V variable between members of the two sexes in each city over time. How

[R] Correlation matrix for data in long format

2008-01-29 Thread Serguei Kaniovski
Arizona,2004,0.36 Thank you in advance for your help, Serguei Kaniovski __ 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

[R] between sum of squares for clusters

2008-01-16 Thread Serguei Kaniovski
Hello, how to compute the between sum of squares the for the clusters obtained by kmeans for the example below? I would like to compute the SSB-SSW based information measures for the clusters, as implemented in cclust, but I am getting an error message. Serguei x1,x2,x3,x4,x5,cl

[R] Quick question on kmeans

2008-01-15 Thread Serguei Kaniovski
Hello, when kmeans draws random vectors for the initial centroids, does it then select the clustering that has emerged most frequently? Serguei __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] Permutations of variables in a dataframe

2008-01-14 Thread Serguei Kaniovski
Hallo All, I would like to apply a function to all permutations of variables in a dataframe (except the first). What is the best way to achieve this? I produce the permutations using: nvar - ncol(dat) - 1 perms - as.matrix( expand.grid(rep( list(1:0) , nvar ))[ , nvar:1] ) Thanks in advance

[R] Information criteria for kmeans

2007-12-05 Thread Serguei Kaniovski
Hello, how is, for example, the Schwarz criterion is defined for kmeans? It should be something like: k - 2 vars - 4 nobs - 100 dat - rbind(matrix(rnorm(nobs, sd = 0.3), ncol = vars), matrix(rnorm(nobs, mean = 1, sd = 0.3), ncol = vars)) colnames(dat) - paste(var,1:4) (cl -

[R] Inserting a subsequence between values of a vector

2007-12-04 Thread Serguei Kaniovski
Hallo, suppose I have a vector: x - c(1,1,1,2,2,3,3,3,3,3,4) How can I generate a vector/sequence in which a fixed number of zeroes (say 3) is inserted between the consecutive values, so I get 1,1,1,0,0,0,2,2,0,0,0,3,3,3,3,3,0,0,0,4 thanks a lot, Serguei [[alternative HTML version

[R] Order observations in a dataframe

2007-11-28 Thread Serguei Kaniovski
of their cumulative weight, which wound be: country;weight;group fra;29;1 ita;29;1 gbr;29;1 bul;10;2 cze;12;2 grc;12;2 hun;12;2 prt;12;2 rom14;2 aut;10;3 bel;12;3 The first group has the largest sum of weights, the second, with the second largest, and so on. Thanks for your help, Serguei Kaniovski

[R] Replacing values job

2007-11-28 Thread Serguei Kaniovski
Hallo, I have two vectors of different lengths which contain the same set of values: X -c(2,6,1,7,4,3,5) Y - c(1,1,6,4,6,1,4,1,2,3,6,6,1,2,4,4,5,4,1,7,6,6,4,4,7,1,2) How can I replace the values in Y with the index (!) of the corresponding values in X. So 2 appears in X in the first

[R] Vectorize a correlation matrix

2007-11-22 Thread Serguei Kaniovski
? Thanks for help, Serguei Kaniovski [[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

[R] Matrix of dummies from a vector

2007-11-22 Thread Serguei Kaniovski
Hallo From a variable x that defines, say, four classes, I would like to define the matrix mat of dummy variables indicating the classes, i.e. x - c(1,1,1,1,2,2,2,3,3,3,4,4) mat - matrix(c(1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,0,1,

[R] How to map clusters to a correlation matrix

2007-11-20 Thread Serguei Kaniovski
Dear All, I have several socio-economic and geographic variables for the 27 EU countries. I would to use these data to derive a correlation matrix between groups of countries (for a different application). I thought of using kmeans to cluster the groups, and then calibrate between group

Re: [R] How to map clusters to a correlation matrix

2007-11-20 Thread Serguei Kaniovski
To Walter, I am building a model of voting in the EU Council of Ministers. A voting scenario assumes the probabilities of yes votes, possible different for each country, and correlation coefficient between them. The country variables (data) reflect the background characteristics that are