Re: [R] Errors with systemfit package and systemfitClassic()

2007-06-07 Thread Arne Henningsen
Hi iamisha1:

Sorry for answering so late!

On Wednesday 09 May 2007 23:47, [EMAIL PROTECTED] wrote:
 I get the following error message after using the sysfit package's function
 'systemfitClassic':

 Error in data[[eqnVar]] : subscript out of bounds

 When I do this:

 MSYS1 - cbind(Y, Num, F, PO, PD, GO, GD)
 MigOLS1 - systemfitClassic(OLS, F ~ PO + PD + GO + GD, eqnVar = Num,
 timeVar = Y, data = MSYS1) and I get this error message:

Argument data must be a data.frame (please read the documentation!).
Hence,
   systemfitClassic( [...], data = as.data.frame( MSYS1 ) ) 
or 
   MSYS1 - as.data.frame( cbind(Y, Num, F, PO, PD, GO, GD) )
should work.

Arne


 Error in inherits(x, factor) : attempt to select more than one element

 when I do this (removing quotes from columns set as 'eqnVar' and
 'timeVar'):

 MSYS1 - cbind(Y, Num, F, PO, PD, GO, GD)
 MigOLS1 - systemfitClassic(OLS, F ~ PO + PD + GO + GD, eqnVar = Num,
 timeVar = Y, data = MSYS1)

 When I query 'typeof()' I get the following:

 Y: Integer
 Num: Integer
 F: Integer
 PO: Integer
 PD: Integer
 GO: Double
 GD: Double

 I have set my data up in a manner analogous to that in the examples in the
 systemfit documentation.  Also, the panel is balanced.  If it matters, here
 are some descriptions of the data:

 Y: Year
 Num: ID of Flow
 F: Flow
 PO: Origin Population
 PD: Destination Population
 GO: Origin GDP
 GD: Destination GDP
   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch 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.

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch 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] WLS ins systemfit question

2006-07-19 Thread Arne Henningsen
On Wednesday 19 July 2006 16:22, Benn Fine wrote:
 How does one specify the weights for WLS in the
 systemfit command ?

 That is, there is a weight option in lm(), but there
 doesn't seem to be weight option for systemfit(WLS)

WLS in systemfit means that the different _equations_ (not the observations) 
are weighted differently. The weights of the equations are taken from a 
first-step OLS regression by taking the (inverse of the) residual variances 
of each equation. Of course, this can be iterated. The WLS estimation is 
similar to SUR but in WLS all off-diagonal elements of the residual 
covariance matrix are constrained to be zero.

Best regards,
Arne



 Thanks!

 __
 R-help@stat.math.ethz.ch 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.

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch 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] A question about linear optimizaton

2006-05-06 Thread Arne Henningsen
Dear Cathy,

a few comments to your question:

a) If you want a (linear or non-linear) optimization you need an objective 
function that you want to minimize or maximize. 

b) There is no unique solution for your problem.

c) In you case you should use algebra rather than a computer. This gives 
following solution: X1 = 1/8; X2 = 7/8 - X3 with X3 in (7/16, 3/4) = X2 in 
(1/8, 7/16)

Arne

On Friday 05 May 2006 03:58, cathy_chien wrote:
  Dear all,

I am trying to find a solution satisfying the below equations

in R.


Set up the problem

   9 X1+ X2 + X3 = 2
 X1+ X2 + X3 = 1

which is subjected to

0  X1  X2  X3  2.

I have downloaded the packages \'linprog\' and \'lpSolve\' but can

 not see how to solve the question.


 Thank you for your help.


 With Best,

 Cathy

 ==
  五月電腦職訓限額50名
  http://edm-prg.epaper.com.tw/click.php?ad_code=1196890
 ==
  SkypeOut 打美加0.7元/分  打大陸0.9元/分  立即購買
  http://skype.pchome.com.tw/skypeout.htm

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] [R-pkgs] New version of 'systemfit'

2006-03-21 Thread Arne Henningsen
Dear R users,

The authors of the systemfit package have released a new version of this 
package with substantial enhancements. 
The systemfit package contains functions for fitting simultaneous systems of 
linear equations using Ordinary Least Squares (OLS), Weighted Least Squares 
(WLS), Seemingly Unrelated Regressions (SUR), Two-Stage Least Squares (2SLS), 
Weighted Two-Stage Least Squares (W2SLS), and Three-Stage Least Squares 
(3SLS). 
The new enhancements include the ability to test linear restrictions using an 
F, Wald or likelihood-ratio test and the ability to test model specification 
using the Hausman test. The major enhancements include better estimation 
using large data sets as well as many minor improvements, e.g. the ability to 
define how the residual covariance matrix and degrees of freedom are 
computed. The new version includes a wrapper function systemfitClassic that 
can be applied to (classical) panel-like data in long format. Furthermore, 
version 0.8-0 includes additional documentation 
(inst/doc/vignette_systemfit.pdf).

Jeff D. Hamann
Arne Henningsen


-- 
Jeff D. Hamann
Forest Informatics, Inc.
PO Box 1421
Corvallis, Oregon 97339-1421
phone 541-754-1428
[EMAIL PROTECTED]
www.forestinformatics.com

and

Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Heckman regression / adjustment for standard errors?

2006-02-20 Thread Arne Henningsen
Hi Brian,

On Friday 17 February 2006 22:30, Brian Perron wrote:
 Hello folks,

 I am trying to estimate the two-step Heckman regression model.  I would
 like to make an adjustment for intragroup correlations.  Stata can
 implement this with the cluster option, but I am really hoping to stick
 with R.  It seems that the micEcon package is the primary source for this
 two-step regression model (i.e., heckit), but I can't find a way to make
 the adjustment.  Am I overlooking something with this package or other
 packages?

The heckit() function in the micEcon package definitively has no cluster 
option. Unfortunately, I don't know anything about adjustment for intragroup 
correlations in heckman type estimations. Is this difficult to implement? Do 
you know a description of this procedure? (Maybe we can do this together.)

Arne


 Brian

   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problem with NLSYSTEMFIT()

2006-01-12 Thread Arne Henningsen
Dear Kilian,

On Thursday 12 January 2006 14:20, Kilian Plank wrote:
 Hello,



 I want to solve a nonlinear 3SLS problem with nlsystemfit(). The
 equations

 are of the form

 y_it = f_i(x,t,theta)

 The functions f_i(.) have to be formulated as R-functions. When invoking

 nlsystemfit() I get the error



 Error in deriv.formula(eqns[[i]], names(parmnames)) :

 Function 'f1' is not in the derivatives table



 Isn't it possible to provide equations in the form

 eq1 ~ f1(x,t,theta) etc. to nlsystemfit() ?

Unfortunately, this is not (yet) possible. You have to specify your equations 
like eq1 - y ~ b0 + x1^b1 + b1^2 * log( x2) (see the documentation of 
nlsystemfit). Furthermore, I suggest that you ask the author of nlsystemfit 
(Jeff Hamann, see cc) how reliable the algorithms for the non-linear 
estimation are in the current version of systemfit (while the code for the 
linear estimation is very mature now, the non-linear estimation is still 
under development). You are invited to help us improving the code of 
nlsystemfit ;-)

Best wishes,
Arne

 Kind regards,



 Kilian Plank


   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] masked from package:base?

2005-12-02 Thread Arne Henningsen
On Friday 02 December 2005 09:00, you wrote:
 On 12/1/05, Arne Henningsen [EMAIL PROTECTED] wrote:
  On Friday 02 December 2005 02:50, August Berg wrote:
   I am confused by the following description in
 
  http://www.maths.lth.se/help/R/.R/library/systemfit/html/hausman.systemfi
 t .
 
  html
  
   what does the Not run mean?
 
  This means that the command library( systemfit ) is not executed when
  the
  package is checked by R CMD check.
 
  @Jeff: I think we should remove library( systemfit ) from the example
  section, because everybody should know this.
 
   if we do not load systemfit, how can we run
   the following code?
  
   ## Not run: library( systemfit )
  
   data( kmenta )
   attach( kmenta )
   ...
  
   I install the package of systemfit, and run the code.
  
   I got the warning:
library( systemfit )
data( kmenta )
attach( kmenta )
  
   The following object(s) are masked from package:base :
  
q
 
  The data set kmenta has a (column) name called q
  R names(kmenta)
  [1] q p d f a
 
  If you attach these data to the search path, there are two objects with
  the
  name q: the quantity from Kmenta's data set and the function to quit R.
  Hence, attaching this data set masks the function q (quit) from the
  package
  called base. However, you don't have to worry, because q() and ?q
  still
  work as expected.
 
  @Jeff: Since using attach is often troublesome, I suggest that we
  remove attach( kmenta ) from the example section and use systemfit(
  ..., data =
  kmenta ) instead.
 
  Best wishes,
  Arne

 Thanks. But still report such an error:
  pval - 1 - pchisq( h, dim( fit3sls$bcov )[1] )

 Error in pchisq(q, df, lower.tail, log.p) :
 Non-numeric argument to mathematical function

The object h is not numeric, but a list:
R class(h)
[1] hausman.systemfit
R names(h)
[1] qqVar mdf   pval

You probably want this:
R pval - 1 - pchisq( h$m, dim( fit3sls$bcov )[1] )

Or you can just type
R h
2.53565 (P-value: 0.924389)

This is documented in the systemfit manual, please type
R ?hausman.systemfit

Best wishes,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] masked from package:base?

2005-12-02 Thread Arne Henningsen
On Friday 02 December 2005 09:58, you wrote:
 On 12/2/05, Arne Henningsen [EMAIL PROTECTED] wrote:
  On Friday 02 December 2005 09:00, you wrote:
   On 12/1/05, Arne Henningsen [EMAIL PROTECTED] wrote:
On Friday 02 December 2005 02:50, August Berg wrote:
 I am confused by the following description in
 
  http://www.maths.lth.se/help/R/.R/library/systemfit/html/hausman.systemfi
 
   t .
   
html

 what does the Not run mean?
   
This means that the command library( systemfit ) is not executed
 
  when
 
the
package is checked by R CMD check.
   
@Jeff: I think we should remove library( systemfit ) from the
 
  example
 
section, because everybody should know this.
   
 if we do not load systemfit, how can we run
 the following code?

 ## Not run: library( systemfit )

 data( kmenta )
 attach( kmenta )
 ...

 I install the package of systemfit, and run the code.

 I got the warning:
  library( systemfit )
  data( kmenta )
  attach( kmenta )

 The following object(s) are masked from package:base :

  q
   
The data set kmenta has a (column) name called q
R names(kmenta)
[1] q p d f a
   
If you attach these data to the search path, there are two objects
 
  with
 
the
name q: the quantity from Kmenta's data set and the function to
quit
 
  R.
 
Hence, attaching this data set masks the function q (quit) from the
package
called base. However, you don't have to worry, because q() and
 
  ?q
 
still
work as expected.
   
@Jeff: Since using attach is often troublesome, I suggest that we
remove attach( kmenta ) from the example section and use
systemfit( ..., data =
kmenta ) instead.
   
Best wishes,
Arne
  
   Thanks. But still report such an error:
pval - 1 - pchisq( h, dim( fit3sls$bcov )[1] )
  
   Error in pchisq(q, df, lower.tail, log.p) :
   Non-numeric argument to mathematical function
 
  The object h is not numeric, but a list:
  R class(h)
  [1] hausman.systemfit
  R names(h)
  [1] qqVar mdf   pval
 
  You probably want this:
  R pval - 1 - pchisq( h$m, dim( fit3sls$bcov )[1] )
 
  Or you can just type
  R h
  2.53565 (P-value: 0.924389)
 
  This is documented in the systemfit manual, please type
  R ?hausman.systemfit
 
  Best wishes,
  Arne
 
  --
  Arne Henningsen
  Department of Agricultural Economics
  University of Kiel
  Olshausenstr. 40
  D-24098 Kiel (Germany)
  Tel: +49-431-880 4445
  Fax: +49-431-880 1397
  [EMAIL PROTECTED]
  http://www.uni-kiel.de/agrarpol/ahenningsen/

 I see. I guess there is a typo in
 http://www.maths.lth.se/help/R/.R/library/systemfit/html/hausman.systemfit
 on that webpage, pval - 1 - pchisq( h, dim( fit3sls$bcov )[1] )

Nope, this is the documentation to an old version of systemfit.

 Also, is there any way to open the data in atable(I apologize this is not a
 question spefific for the Hausman test).

Which data? kmenta? What do you mean with open?
R edit( kmenta )
or:
R write.csv( kmenta, kmenta.csv )
open the file kmenta.csv with a spreadsheet application.

Best wishes,
Arne

 Best Regards,
 August

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] masked from package:base?

2005-12-02 Thread Arne Henningsen
On Friday 02 December 2005 10:21, August Berg wrote:
 On 12/1/05, Arne Henningsen [EMAIL PROTECTED] wrote:
  On Friday 02 December 2005 02:50, August Berg wrote:
   I am confused by the following description in
 
  http://www.maths.lth.se/help/R/.R/library/systemfit/html/hausman.systemfi
 t .
 
  html
  
   what does the Not run mean?
 
  This means that the command library( systemfit ) is not executed when
  the
  package is checked by R CMD check.
 
  @Jeff: I think we should remove library( systemfit ) from the example
  section, because everybody should know this.

 I am new to R and what does [checked by R CMD check] mean?

The source of an R package can be checked by the command 
   R CMD check package_name 
(on a  Unix/Linux machines; on Windows machines this is slightly different).
Further information is available in the manual Writing R Extensions.

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] masked from package:base?

2005-12-01 Thread Arne Henningsen
On Friday 02 December 2005 02:50, August Berg wrote:
 I am confused by the following description in
 http://www.maths.lth.se/help/R/.R/library/systemfit/html/hausman.systemfit.
html

 what does the Not run mean? 

This means that the command library( systemfit ) is not executed when the 
package is checked by R CMD check. 

@Jeff: I think we should remove library( systemfit ) from the example 
section, because everybody should know this.

 if we do not load systemfit, how can we run 
 the following code?

 ## Not run: library( systemfit )

 data( kmenta )
 attach( kmenta )
 ...

 I install the package of systemfit, and run the code.

 I got the warning:
  library( systemfit )
  data( kmenta )
  attach( kmenta )

 The following object(s) are masked from package:base :

  q

The data set kmenta has a (column) name called q
R names(kmenta)
[1] q p d f a

If you attach these data to the search path, there are two objects with the 
name q: the quantity from Kmenta's data set and the function to quit R. 
Hence, attaching this data set masks the function q (quit) from the package 
called base. However, you don't have to worry, because q() and ?q still 
work as expected.

@Jeff: Since using attach is often troublesome, I suggest that we remove 
attach( kmenta ) from the example section and use systemfit( ..., data = 
kmenta ) instead.

Best wishes,
Arne


   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Fwd: Documenting data sets with many variables

2005-08-17 Thread Arne Henningsen
On Tuesday 16 August 2005 17:26, Gavin Simpson wrote:
 On Tue, 2005-08-16 at 17:11 +0200, Arne Henningsen wrote:
  On Tuesday 16 August 2005 14:49, Roger D. Peng wrote:
   Have you tried using 'promptData()' on the data frame and then
   just using the resulting documentation file?
 
  Thank you, Roger, for bringing 'promptData()' to my mind. This is really
  a useful tool. However, in my special case my aim is to reduce the extent
  and increase the comprehensibility of the documentation rather than to
  reduce my effort to write the documentation.
 
  Any further hints are welcome!
 
  Thanks,
  Arne

 Would it not be expedient then to ignore the \format{} section and just
 provide the information on the variables say in the \description{},
 e.g.:

That's a great idea - and so simple!
This perfectly solves my problem.
Thanks,
Arne

 This example taken from package vegan describing 2 data.frames with 44
 and 14 columns. Admittedly, none of the variables in the species dataset
 are explicitly and individually described in this example, but it is
 sufficient in this case I think.

 \name{varespec}
 \alias{varechem}
 \alias{varespec}
 \docType{data}
 \title{Vegetation and environment in lichen pastures}
 \usage{
data(varechem)
data(varespec)
 }
 \description{
   The \code{varespec} data frame has 24 rows and 44 columns.  Columns
   are estimated cover values of 44 species.  The variable names are
   formed from the scientific names, and are self explanatory for anybody
   familiar with the vegetation type.
 The \code{varechem} data frame has 24 rows and 14 columns, giving the
 soil characteristics of the very same sites as in the \code{varespec}
 data frame. The chemical measurements have obvious names.
 \code{Baresoil} gives the estimated cover of bare soil, \code{Humpdepth}
 the thickness of the humus layer.

 }
 

 HTH

 G

   -roger
  
   Arne Henningsen wrote:
Hi,
   
since nobody answered to my first message, I try to explain my
problem more clearly and more general this time:
   
I have a data set in my R package micEcon, which has many variables
(82). Therefore, I would like to avoid to describe all variables in
the \format section of the documentation (.Rd file). However, doing
this lets R CMD check complain about data codoc mismatches
(details see below). Is there a way to avoid the description of all
variables without getting a complaint from R CMD check?
   
Thanks,
Arne
   
   
--  Forwarded Message  --
   
Subject: Documenting data sets with many variables
Date: Friday 05 August 2005 14:03
From: Arne Henningsen [EMAIL PROTECTED]
To: R-help@stat.math.ethz.ch
   
Hi,
   
I extended the data set Blanciforti86 that is included in my R
package micEcon. For instance, I added consumer prices, annual
consumption expenditures and expenditure shares of eleven aggregate
commodity groups. The corresponding variables in the data frame are
called pAgg1, pAgg2, ..., pAgg11, xAgg1, xAgg2, ...,
xAgg11, wAgg1, wAgg2, ..., wAgg11. To avoid to describe all
33 items in the \format section of the documentation (.Rd file) I
wrote something like
   
\format{
   This data frame contains the following columns:
   \describe{
  [ . . . ]
  \item{xAggX}{Expenditure on the aggregate commodity group X
 (in Millions of US-Dollars).}
  \item{pAggX}{Price index for the aggregate commodity group X
 (1972 = 100).}
  \item{wAggX}{Expenditure share of the aggregate commodity group
X.} [ . . . ]
   }
}
   
and explained the 11 aggregate commodity groups only once in a
different section (1=food, 2=clothing, ... ). However, R CMD check
now complains about data codoc mismatches, e.g.
  Code: [...] pAgg1pAgg2 pAgg3  [...]
  Docs: [...] pAggX [...]
   
Is there a way to avoid the description of all 33 items without
getting a complaint from R CMD check?
   
Thanks,
Arne
   
---

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Fwd: Documenting data sets with many variables

2005-08-16 Thread Arne Henningsen
Hi, 

since nobody answered to my first message, I try to explain my problem more 
clearly and more general this time:

I have a data set in my R package micEcon, which has many variables (82). 
Therefore, I would like to avoid to describe all variables in the \format 
section of the documentation (.Rd file). However, doing this lets R CMD 
check complain about data codoc mismatches (details see below).
Is there a way to avoid the description of all variables without getting a
complaint from R CMD check?

Thanks,
Arne


--  Forwarded Message  --

Subject: Documenting data sets with many variables
Date: Friday 05 August 2005 14:03
From: Arne Henningsen [EMAIL PROTECTED]
To: R-help@stat.math.ethz.ch

Hi,

I extended the data set Blanciforti86 that is included in my R package
micEcon. For instance, I added consumer prices, annual consumption
expenditures and expenditure shares of eleven aggregate commodity groups.
The corresponding variables in the data frame are called pAgg1,
pAgg2, ..., pAgg11, xAgg1, xAgg2, ..., xAgg11, wAgg1,
wAgg2, ..., wAgg11. To avoid to describe all 33 items in the \format
section of the documentation (.Rd file) I wrote something like

\format{
   This data frame contains the following columns:
   \describe{
  [ . . . ]
  \item{xAggX}{Expenditure on the aggregate commodity group X
 (in Millions of US-Dollars).}
  \item{pAggX}{Price index for the aggregate commodity group X
 (1972 = 100).}
  \item{wAggX}{Expenditure share of the aggregate commodity group X.}
  [ . . . ]
   }
}

and explained the 11 aggregate commodity groups only once in a different
section (1=food, 2=clothing, ... ). However, R CMD check now complains
about data codoc mismatches, e.g.
  Code: [...] pAgg1pAgg2 pAgg3  [...]
  Docs: [...] pAggX [...]

Is there a way to avoid the description of all 33 items without getting a
complaint from R CMD check?

Thanks,
Arne

---

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Fwd: Documenting data sets with many variables

2005-08-16 Thread Arne Henningsen
On Tuesday 16 August 2005 14:49, Roger D. Peng wrote:
 Have you tried using 'promptData()' on the data frame and then
 just using the resulting documentation file?

Thank you, Roger, for bringing 'promptData()' to my mind. This is really a 
useful tool. However, in my special case my aim is to reduce the extent and 
increase the comprehensibility of the documentation rather than to reduce my 
effort to write the documentation. 

Any further hints are welcome!

Thanks,
Arne

 -roger

 Arne Henningsen wrote:
  Hi,
 
  since nobody answered to my first message, I try to explain my problem
  more clearly and more general this time:
 
  I have a data set in my R package micEcon, which has many variables
  (82). Therefore, I would like to avoid to describe all variables in the
  \format section of the documentation (.Rd file). However, doing this
  lets R CMD check complain about data codoc mismatches (details see
  below). Is there a way to avoid the description of all variables without
  getting a complaint from R CMD check?
 
  Thanks,
  Arne
 
 
  --  Forwarded Message  --
 
  Subject: Documenting data sets with many variables
  Date: Friday 05 August 2005 14:03
  From: Arne Henningsen [EMAIL PROTECTED]
  To: R-help@stat.math.ethz.ch
 
  Hi,
 
  I extended the data set Blanciforti86 that is included in my R package
  micEcon. For instance, I added consumer prices, annual consumption
  expenditures and expenditure shares of eleven aggregate commodity groups.
  The corresponding variables in the data frame are called pAgg1,
  pAgg2, ..., pAgg11, xAgg1, xAgg2, ..., xAgg11, wAgg1,
  wAgg2, ..., wAgg11. To avoid to describe all 33 items in the
  \format section of the documentation (.Rd file) I wrote something like
 
  \format{
 This data frame contains the following columns:
 \describe{
[ . . . ]
\item{xAggX}{Expenditure on the aggregate commodity group X
   (in Millions of US-Dollars).}
\item{pAggX}{Price index for the aggregate commodity group X
   (1972 = 100).}
\item{wAggX}{Expenditure share of the aggregate commodity group X.}
[ . . . ]
 }
  }
 
  and explained the 11 aggregate commodity groups only once in a different
  section (1=food, 2=clothing, ... ). However, R CMD check now complains
  about data codoc mismatches, e.g.
Code: [...] pAgg1pAgg2 pAgg3  [...]
Docs: [...] pAggX [...]
 
  Is there a way to avoid the description of all 33 items without getting a
  complaint from R CMD check?
 
  Thanks,
  Arne
 
  ---

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Documenting data sets with many variables

2005-08-05 Thread Arne Henningsen
Hi,

I extended the data set Blanciforti86 that is included in my R package 
micEcon. For instance, I added consumer prices, annual consumption 
expenditures and expenditure shares of eleven aggregate commodity groups. 
The corresponding variables in the data frame are called pAgg1, 
pAgg2, ..., pAgg11, xAgg1, xAgg2, ..., xAgg11, wAgg1, 
wAgg2, ..., wAgg11. To avoid to describe all 33 items in the \format 
section of the documentation (.Rd file) I wrote something like

\format{
   This data frame contains the following columns:
   \describe{
  [ . . . ]
  \item{xAggX}{Expenditure on the aggregate commodity group X
 (in Millions of US-Dollars).}
  \item{pAggX}{Price index for the aggregate commodity group X 
 (1972 = 100).}
  \item{wAggX}{Expenditure share of the aggregate commodity group X.}
  [ . . . ]
   }
}

and explained the 11 aggregate commodity groups only once in a different 
section (1=food, 2=clothing, ... ). However, R CMD check now complains 
about data codoc mismatches, e.g. 
  Code: [...] pAgg1pAgg2 pAgg3  [...] 
  Docs: [...] pAggX [...] 

Is there a way to avoid the description of all 33 items without getting a 
complaint from R CMD check?

Thanks,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] elegant matrix creation

2005-07-12 Thread Arne Henningsen
Maybe not elegant, but I guess this function does what you want:

f - function( x ) {
   n - length( x ) + 1
   m - matrix( 0, nrow = n, ncol = n )
   diag(m) - 1
   for( j in 1:( n-1 ) ) {
  for( i in ( j+1 ):n ) {
 m[ i, j ] - prod( x[ j:(i-1) ] )
  }
   }
   return( m )
}

Best wishes,
Arne

On Tuesday 12 July 2005 13:11, Robin Hankin wrote:
 Hi

 I want to write a little function that takes a vector of arbitrary
 length n and returns a matrix of size n+1 by n+1.

 I can't easily describe it, but the following function that works for
 n=3 should convey what I'm trying to do:


 f - function(x){
matrix(c(
 1   ,   0  ,   0 , 0,
 x[1]  ,   1  ,   0 , 0,
 x[1]*x[2] , x[2] ,   1 , 0,
 x[1]*x[2]*x[3], x[2]*x[3], x[3], 1
 ),
 4,4, byrow=T)
 }

 f(c(10,7,2))
   [,1] [,2] [,3] [,4]
 [1,]1000
 [2,]   10100
 [3,]   70710
 [4,]  140   1421



 As one goes down column i, the entries get multiplied by successive
 elements of x,  starting with x[i], after the first 1

 As one goes along a row, one takes a product of the tail end of x,
 until the zeroes kick in.


 Am I missing some clever solution?



 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
   tel  023-8059-7743

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] an operator for contains

2005-06-17 Thread Arne Henningsen
%in%

R k - 1:9
R 3 %in% k
[1] TRUE
R 33 %in% k
[1] FALSE

Arne

On Friday 17 June 2005 22:31, Mike R wrote:
 k = c(1:9)
 if( length( which(k==3) ) ){ print(contained) }else{ print(not
 contained) }

 is therre a simple way to test if a vector/list contains a particular
 value?

 for example an operator, along the lines of: ==

 more generally, is the a documentaion page that lists/describes all
 such operators?

 lastly, if you didn't know the answer to my question, how would you have
 gone about searching for an answer?  I tried RSiteSearch() using various
 terms, and I opened  R-2.1.0/library/base/html/00Index.html and searched
 for various terms.

 TIA

 ==
 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status
 major2
 minor1.0
 year 2005
 month04
 day  18
 language R

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problem with systemfit 0.7-3 and transformed variables

2005-05-25 Thread Arne Henningsen
On Wednesday 25 May 2005 11:43, Mikko Pakkanen wrote:
 The 'systemfit' function in systemfit 0.7-3 CRAN package seems to have a
 problem with formulas that contain transformed (eg. log) variables. If I
 have my data in a data frame, apparently systemfit doesn't pass the
 information of where the variables should be taken to the transforming
 function.

 I'm not entirely sure if this is a bug or just a limitation, I was just
 surprised when I attempted to estimate a model, which I'd previously
 estimated with OLS using 'lm', with 2SLS using 'systemfit' and it didn't
 accept those transformations like 'lm' does.

 Here's an example: this is, of course, OK:
  data(kmenta)
  demand - q ~ p + d
  instr - ~ d + f
  fit1 - systemfit(2SLS, eqns=list(demand), inst=instr, data=kmenta)

 But, now if I'd like to estimate a model with logarithm of p as a
 regressor,

 an error occurs:
  demand2 - q ~ log(p) + d
  fit2 - systemfit(2SLS, eqns=list(demand2), inst=instr, data=kmenta)

 Error in log(p) : Object p not found

 However, estimating the same formula with OLS using the regular 'lm' is OK:
  fit2.ols - lm(demand2, kmenta)

 Transforming an instrument causes the same error too:
  instr2 - ~ log(d) + f
  fit3 - systemfit(2SLS, eqns=list(demand), inst=instr2, data=kmenta)

 Error in log(d) : Object d not found

 One could certainly just create those transformed variables to avoid the
 problem, but it would be much more convenient, if it wasn't necessary,
 especially if several regressors are involved.

We did not notice this shortcoming of systemfit() so far. Unfortunately, I 
don't have the time in the next few days to look into the code and figure out 
how to enable transformed variables. I suggest that you either create 
transformed variables by hand or you modify the systemfit code to enable this 
and send us the patch. I prefer the second :-) (that's the philosophy of 
open-source software like R: useRs become developeRs).

Best wishes,
Arne

  version

  _
 platform i386-pc-mingw32
 arch i386
 os   mingw32
 system   i386, mingw32
 status
 major2
 minor1.0
 year 2005
 month04
 day  18
 language R

 Regards,

 -Mikko Pakkanen

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Linear system

2005-05-25 Thread Arne Henningsen
On Wednesday 25 May 2005 14:30, Jim Gustafsson wrote:
 Dear R-help

 I have a problem solving a linear system like

 353a+45b+29c=79
 45a+29b+3c=5
 29a+3b+4c=8

 Is there any way of doing this in R?


You can write this equation system in matrix form:
M * x = y

with 
x = ( a, b, c )
M = ( 353, 45, 29,
   45, 29,  3,
   29,  3,  4 )
y = ( 79, 5, 8 )

you can solve the system by 
x = M^(-1) * y

In R you can do this by
R M = matrix( c( 353, 45, 29, 45, 29,  3, 29,  3,  4 ), 
   ncol = 3, byrow = TRUE )
R y - c( 79, 5, 8 )
R x - solve( M ) %*% y 
or
R x - solve( M, y )

Please read a basic book about linear algebra.

Arne


 Best Regards
 Jim


 ---
--- This e-mail and any attachment may be confidential and may also be
 privileged. If you are not the intended recipient, please notify us
 immediately and then delete this e-mail and any attachment without
 retaining copies or disclosing the contents thereof to any other person.
 Thank you.
 ---
--- [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problem with systemfit 0.7-3 and transformed variables

2005-05-25 Thread Arne Henningsen
On Wednesday 25 May 2005 18:25, Mikko Pakkanen wrote:
  We did not notice this shortcoming of systemfit() so far. Unfortunately,
  I
  don't have the time in the next few days to look into the code and figure
  out
  how to enable transformed variables. I suggest that you either create
  transformed variables by hand or you modify the systemfit code to enable
  this
  and send us the patch. I prefer the second :-) (that's the philosophy of
  open-source software like R: useRs become developeRs).

 Luckily, I had some time to check the code. Debugger revealed that the
 problems are caused by the model.frame function which is used to compile
 the '$data' data frame. I don't need that data frame so much, so I just
 substituted model.frame with model.matrix which apparently doesn't cause
 this error with transformed variables. However, I tuned it a bit further,
 so that it should still return an identical '$data' data frame, despite the
 modification.
 I've only tested this with my example and it appears to be OK. Still, I
 think this should be considered a quick  dirty fix -there are probably
 better ways to do it. But, I hope it gives the idea. Here's my attempt:

 [EMAIL PROTECTED] R $ diff -u systemfit.R systemfit-patched.R
 --- systemfit.R 2004-11-26 11:17:36.0 +0200
 +++ systemfit-patched.R 2005-05-25 18:55:55.568944699 +0300
 @@ -624,7 +624,11 @@
  Terms - terms( eqns[[i]], data = data)
  m$formula - Terms
  m - eval(m, parent.frame())
 -datai - model.frame(Terms, m)
 +resp - model.extract(m, response)
 +   ## using model.matrix instead of model.frame, need to get the
 output variable separately
 +datai - data.frame(cbind(resp, (model.matrix(Terms, m))[,-1]))
 +   ## I guess there's a better way to extract the name of the output
 variable?
 +   names(datai)[1] - as.character(terms(eqns[[i]]))[2]
  if(method==2SLS | method==3SLS) {
#datai - cbind( datai, model.frame( instl[[i]] ))
# the following lines have to be substituted for the previous
 @@ -634,7 +638,8 @@
Terms - terms(instl[[i]], data = data)
m$formula - Terms
m - eval(m, parent.frame())
 -  datai - cbind( datai, model.frame(Terms, m))
 +  ## used previously model.frame
 +  datai - cbind( datai, as.data.frame((model.matrix(Terms, m))[,-1]))
  }

  if(i==1) {

Thank you very much for the patch. I have uploaded a patched version of 
systemfit (version 0.7-4) to CRAN. It is also available on my website now:
   http://www.uni-kiel.de/agrarpol/ahenningsen/index-e.html 

Best wishes,
Arne

 Regards,

 -Mikko.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] constraints

2005-05-22 Thread Arne Henningsen
On Sunday 22 May 2005 03:18, Ingmar Visser wrote:
 Is there a package in R that handles general linear (in-)equality + box
 constrained optimization?

R help.search(constrained optimisation)
constrOptim(stats)  Linearly constrained optimisation

Best wishes,
Arne

 If it is not there, could anyone advise me which way to go?
 And/or point me to packages that solve these problems partially?
 best, ingmar

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] constrained optimization

2005-05-20 Thread Arne Henningsen
On Friday 20 May 2005 17:32, [EMAIL PROTECTED] wrote:
 Hello,
 I've got to compute a minimization equation under an equality constraint
 (Min g(x1,x2,x3) with x1+x2=const). The Constroptim function does not
 authorize an equality condition but only inequality conditions. Which
 function can I use instead?
 Thank you very much for your help.
 Gael Robert - +33 1 42 14 27 96

You do not need constraints if you minimize
   g( x1, const - x1, x3 )
with respect to x1 and x3. After that you can calculate x2 by
   x2 = const - x1

HTH,
Arne

 **
 This message and any attachments (the message) are confide...{{dropped}}

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Multivariate multiple regression

2005-05-06 Thread Arne Henningsen
On Wednesday 04 May 2005 20:08, Iain Pardoe wrote:
 I'd like to model the relationship between m responses Y1, ..., Ym and a
 single set of predictor variables X1, ..., Xr.  Each response is assumed
 to follow its own regression model, and the error terms in each model
 can be correlated.  My understanding is that although lm() handles
 vector Y's on the left-hand side of the model formula, it really just
 fits m separate lm models.  What should I use to do a full multivariate
 analysis (as in section 7.7 of Johnson/Wichern)?  Thanks.

I don't know Johnson/Wichern. However, it seems to me that you want to do a 
seemingly unrelated regression (SUR). You can do this with the package 
systemfit.

Arne

 Iain Pardoe [EMAIL PROTECTED]
 University of Oregon

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] opimization problem

2005-05-02 Thread Arne Henningsen
Hi Gottfried,

w' * V * w is not a restriction, because there is no equal sign. 
Do you mean w' * V * w = 1?

Arne
 
On Sunday 01 May 2005 19:21, Gottfried Gruber wrote:
 hi,

 i want to execute the following opimization problem:
 max r*w
 s.t.:   w*z=1 # sum of w is 1
 r, w are [nx1] vectors, z is a [nx1] vector consisting of 1
 so far so good, works fine with lp

 the problem arises with the additional restriction
 w' * V * w
 where V is a [nxn] matrix
 how can i include this restriction since w arises twice?

 thanks,
 gg

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to add some of data in the first place dataset

2005-04-27 Thread Arne Henningsen
If you want to add rows to a data frame using rbind, your additional rows must 
be in a data frame with the same (column) names.

R data( iris )
R a - data.frame( Sepal.Length=c(1:4), Sepal.Width=c(2:5), 
  Petal.Length=c(3:6), Petal.Width=c(4:7), Species=rep(rosa,4))
R b - iris[1:10,]
R rbind(a,b)
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   1.0 2.0  3.0 4.0rosa
2   2.0 3.0  4.0 5.0rosa
3   3.0 4.0  5.0 6.0rosa
4   4.0 5.0  6.0 7.0rosa
11  5.1 3.5  1.4 0.2  setosa
21  4.9 3.0  1.4 0.2  setosa
31  4.7 3.2  1.3 0.2  setosa
41  4.6 3.1  1.5 0.2  setosa
5   5.0 3.6  1.4 0.2  setosa
6   5.4 3.9  1.7 0.4  setosa
7   4.6 3.4  1.4 0.3  setosa
8   5.0 3.4  1.5 0.2  setosa
9   4.4 2.9  1.4 0.2  setosa
10  4.9 3.1  1.5 0.1  setosa


Arne

On Wednesday 27 April 2005 15:48, Muhammad Subianto wrote:
 Dear R-help,
  First I apologize if my question is quite simple.
  I need add some of data in the first place my dataset, how can I do that.
  I have tried with rbind, but I did not succes.
0.1 3.6  0.4 0.9  rose
4.1 4.0  1.2 1.2  rose
4.4 3.2  1.9 0.5  rose
4.6 1.1  1.1 0.2  rose
  For example,

   data(iris)
   iris[1:10,]

 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
  1   5.1 3.5  1.4 0.2  setosa
  2   4.9 3.0  1.4 0.2  setosa
  3   4.7 3.2  1.3 0.2  setosa
  4   4.6 3.1  1.5 0.2  setosa
  5   5.0 3.6  1.4 0.2  setosa
  6   5.4 3.9  1.7 0.4  setosa
  7   4.6 3.4  1.4 0.3  setosa
  8   5.0 3.4  1.5 0.2  setosa
  9   4.4 2.9  1.4 0.2  setosa
  10  4.9 3.1  1.5 0.1  setosa

  The result something like this,

0.1 3.6  0.4 0.9  rose
4.1 4.0  1.2 1.2  rose
4.4 3.2  1.9 0.5  rose
4.6 1.1  1.1 0.2  rose
5.1 3.5  1.4 0.2  setosa
4.9 3.0  1.4 0.2  setosa
4.7 3.2  1.3 0.2  setosa
4.6 3.1  1.5 0.2  setosa
5.0 3.6  1.4 0.2  setosa
5.4 3.9  1.7 0.4  setosa
4.6 3.4  1.4 0.3  setosa
5.0 3.4  1.5 0.2  setosa
4.4 2.9  1.4 0.2  setosa
4.9 3.1  1.5 0.1  setosa

  Sincerely,
  Muhammad Subianto

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] writing a data frame in excel format

2005-04-26 Thread Arne Henningsen
I save my data(frames) in csv format, which can be opened by any spreadsheet 
application:

R write.table( myData, myFile.csv, col.names = NA, sep = , )

Arne

On Tuesday 26 April 2005 04:28, Mario Morales wrote:
 Hello

 I know how read a file in excel format into a R data frame using the
 RODBC library, but I don't know how write a R data frame in excel
 format. I don't understand the instructions from RODBC user manual.

 To read an excel file I use.

 library(RODBC);

 conex-odbcConnectExcel(fis_quim.xls);

 sqlTables(conex);

 data-sqlFetch(conex,hoja1);

 Suppose I modify data and I want to save it as an excel file, How do
 I do that?

 Thanks for your help

 Mario Alfonso Morales Rivera
 Profesor Auxiliar.
 Departamento de Matemáticas y Estadistica.
 Universidad de Córdoba.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] heckit / tobit estimation

2005-04-20 Thread Arne Henningsen
Dear All,

we (Ott Toomet and I) would like to add  functions for maximum likelihood (ML) 
estimations of generalized tobit models of type 2 and type 5 (*see below)  in 
my R package for microeconomic analysis micEcon. So far we have called 
these functions tobit2( ) and tobit5( ). 
Are these classifications well known? How are these functions called in other 
software packages? Should we keep these names or does anybody have better 
suggestions? 

(* T. Amemiya (1984): Tobit models: a survey, Journal of Econometrics, and
T. Amemiya (1985): Advanced Econometrics)

Furthermore, the generalized tobit model of type 2 is identical to the Heckman 
model. Until now the package micEcon contains a function heckit( ) that 
performs a two-step estimation of the Heckman / Tobit type 2 model. The 
difference between heckit( ) and tobit2( ) is that heckit( ) performs a 
two-step estimation, while tobit2( ) performs a maximum likelihood 
estimation. At the moment we are debating how to construct the user 
interface. These are our suggestions:

1) Keep it as it is:
heckit( ) does a two-step estimation and
tobit2( ) does a ML estimation

2) Having just one function:
tobit2( ..., method = 2step ) does a two-step estimation
tobit2( ..., method = ML ) does a ML estimation
This has the advantage that other methods like a weighted two-step least 
squares can be added easily.

3) As suggestion 2). Argument method has the default ML and an
additional a wrapper function is added:
heckit - function( ... ) {
   return( tobit2( ..., method = 2step ) )
}

Does anybody have a better suggestion?
How is this implemented in other software packages?
What do you think is the best option?

Thanks,
Arne Henningsen
Ott Toomet


-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] heckit / tobit estimation

2005-04-20 Thread Arne Henningsen
On Wednesday 20 April 2005 14:31, Achim Zeileis wrote:
 Arne:
  we (Ott Toomet and I) would like to add  functions for maximum
  likelihood (ML) estimations of generalized tobit models of type 2 and
  type 5 (*see below)  in my R package for microeconomic analysis
  micEcon. So far we have called these functions tobit2( ) and
  tobit5( ). Are these classifications well known?

 I don't know them, but I'm certainly not an expert in tobit
 estimation...
 Generally, I prefer functions that have a name like tobit() and where
 the rest can be specified by parameters, that can be more easily
 understood than abstract categorizations like type 2 and type 5.

Just having a single tobit() function sounds good. However, the different 
types of tobit models require different arguments, e.g. something like
   tobit1( formula, ... )
   tobit2( selection, formula, ... )
   tobit3( formula1, formula2, ... )
   tobit4( formula1, formula2, formula3, ... )
   tobit5( selection, formula1, formula2, ... )
where selection are binary selection models and formula* are censored 
equations.
I think having a function
   tobit( selection = NULL, formula1 = NULL, formula2 = NULL, 
  formula3 = NULL, ... )
and taking the model type according to which arguments are non-NULL might also 
be confusing. What do you think?

  How are these
  functions called in other software packages? Should we keep these
  names or does anybody have better suggestions?
 
  (* T. Amemiya (1984): Tobit models: a survey, Journal of Econometrics,
  and T. Amemiya (1985): Advanced Econometrics)

 OK, I haven't checked those now, but I guess that it should be possible
 to figure out first what the common *conceptual* properties of the
 different models are and then turn them into *computational* tools. My
 guess would be that type 2 and type 5 are not the best conceivable
 abstractions of the underlying conceptual properties...

  Furthermore, the generalized tobit model of type 2 is identical to the
  Heckman model. Until now the package micEcon contains a function
  heckit( ) that performs a two-step estimation of the Heckman / Tobit
  type 2 model. The difference between heckit( ) and tobit2( ) is
  that heckit( ) performs a two-step estimation, while tobit2( )
  performs a maximum likelihood estimation. At the moment we are
  debating how to construct the user interface. These are our
  suggestions:
 
  1) Keep it as it is:
  heckit( ) does a two-step estimation and
  tobit2( ) does a ML estimation
 
  2) Having just one function:
  tobit2( ..., method = 2step ) does a two-step estimation
  tobit2( ..., method = ML ) does a ML estimation
  This has the advantage that other methods like a weighted two-step
  least squares can be added easily.
 
  3) As suggestion 2). Argument method has the default ML and an
  additional a wrapper function is added:
  heckit - function( ... ) {
 return( tobit2( ..., method = 2step ) )
  }

 Probably, I would allow both, I guess. Thus go for something like 3).

  Does anybody have a better suggestion?
  How is this implemented in other software packages?
  What do you think is the best option?

 How did you implement it, btw? 

The 2-step method follows exactly the proposal of Heckman: a) a probit 
estimation using glm(), b) an OLS using lm() with Inverse Mills Ratio as 
additional regressor. The coefficient covariance matrix and, thus, also the 
standard error of the coefficients are calculated using the formula in 
Greene: Econometric Analysis, 5th edition, p. 785.
The ML estimation was written by Ott. The likelihood value is maximized using 
a Newton-Raphson algorithm, which is implement by him in a supplementary 
function and will be available in the next version of micEcon.

 Christian Kleiber and I have been playing 
 around with some tobit models which we fitted by interfacing survreg().
 We also intend(ed) to write some tobit() function for our AER project
 (which I have told you about offline, I think). Maybe we could pool our
 efforts here, such that the functionality is not duplicated...but we
 should discuss that offline.

 Best,
 Z

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] heckit / tobit estimation

2005-04-20 Thread Arne Henningsen
On Wednesday 20 April 2005 14:48, you wrote:
 For what it is worth, I  agree fully with Achim's view of  naming
 conventions, and also feel that it would be nice to connect these
 fitting methods with the survival stuff, just to cut down on the sense
 that econometrics and biostatistics represent some sort of Balkanization
 of statistics.  

I totally agree. Do you know any good description how tobit models are 
translated into survival models?

 Finally, having done ml type tobit methods it would be 
 nice
 to have an authoritative version of the Powell estimator for these
 models.

The ML estimation was written by Ott and, unfortunately, I do not know the 
authoritative version of the Powell estimator. Maybe, Ott or Roger (or 
somebody else) can implement this.

Arne

 best,

 R.

 url:  www.econ.uiuc.edu/~rogerRoger Koenker
 email [EMAIL PROTECTED]   Department of Economics
 vox:  217-333-4558University of Illinois
 fax:  217-244-6678Champaign, IL 61820

 On Apr 20, 2005, at 7:31 AM, Achim Zeileis wrote:
  Arne:
  we (Ott Toomet and I) would like to add  functions for maximum
  likelihood (ML) estimations of generalized tobit models of type 2 and
  type 5 (*see below)  in my R package for microeconomic analysis
  micEcon. So far we have called these functions tobit2( ) and
  tobit5( ). Are these classifications well known?
 
  I don't know them, but I'm certainly not an expert in tobit
  estimation...
  Generally, I prefer functions that have a name like tobit() and where
  the rest can be specified by parameters, that can be more easily
  understood than abstract categorizations like type 2 and type 5.
 
  How are these
  functions called in other software packages? Should we keep these
  names or does anybody have better suggestions?
 
  (* T. Amemiya (1984): Tobit models: a survey, Journal of Econometrics,
  and T. Amemiya (1985): Advanced Econometrics)
 
  OK, I haven't checked those now, but I guess that it should be possible
  to figure out first what the common *conceptual* properties of the
  different models are and then turn them into *computational* tools. My
  guess would be that type 2 and type 5 are not the best conceivable
  abstractions of the underlying conceptual properties...
 
  Furthermore, the generalized tobit model of type 2 is identical to the
  Heckman model. Until now the package micEcon contains a function
  heckit( ) that performs a two-step estimation of the Heckman / Tobit
  type 2 model. The difference between heckit( ) and tobit2( ) is
  that heckit( ) performs a two-step estimation, while tobit2( )
  performs a maximum likelihood estimation. At the moment we are
  debating how to construct the user interface. These are our
  suggestions:
 
  1) Keep it as it is:
  heckit( ) does a two-step estimation and
  tobit2( ) does a ML estimation
 
  2) Having just one function:
  tobit2( ..., method = 2step ) does a two-step estimation
  tobit2( ..., method = ML ) does a ML estimation
  This has the advantage that other methods like a weighted two-step
  least squares can be added easily.
 
  3) As suggestion 2). Argument method has the default ML and an
  additional a wrapper function is added:
  heckit - function( ... ) {
 return( tobit2( ..., method = 2step ) )
  }
 
  Probably, I would allow both, I guess. Thus go for something like 3).
 
  Does anybody have a better suggestion?
  How is this implemented in other software packages?
  What do you think is the best option?
 
  How did you implement it, btw? Christian Kleiber and I have been
  playing
  around with some tobit models which we fitted by interfacing survreg().
  We also intend(ed) to write some tobit() function for our AER project
  (which I have told you about offline, I think). Maybe we could pool our
  efforts here, such that the functionality is not duplicated...but we
  should discuss that offline.
 
  Best,
  Z
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problems with lpSolve/Memory ? R crashes

2005-03-30 Thread Arne Henningsen
Unfortunately, I can't tell you how to solve this problem. However, I can 
confirm that this crash happens also on my machines (R 2.0.1 on Debian Sarge, 
AMD Athlon, 750 MHz, 256 MB RAM and R 2.0.0 on SuSE 9.0, Intel P4, 2.6 GHz, 
512 MB RAM):
R aaa(1000)
alloc of 8 bytes failed
alloc of 4 bytes failed
Speicherzugriffsfehler

We had a model, which consists of 1000+ linear programs with each about 550 
rows and 1100 columns (http://www.unipr.it/arpa/dipseq/EAAE/PR/Parallel/ 
42b4_henningsen.pdf). On MS-Windows 2000/XP this model always crashed after 
some hundreds linear programs, but using Linux on the same machines it 
_never_ crashed. I really can't see the reason why our much larger programs 
worked, but these small programs let R crash. 
I hope that this information may help to solve this problem.

Arne

On Wednesday 30 March 2005 12:16, TEMPL Matthias wrote:
 Hello!

 I have a curious problem, which I cannot solve.
 With my code I solve thousands of small linear programs with the package
 lpSolve automatically. But R crashes sometimes (~always, but always on
 different linear programs) in a strange way. For illustration, I tried to
 prepare a simple example, which shows the nature of the problem. The
 function aaa (see below) declares some constants (only in this special
 example) and in the end it solves the linear program.

 aaa(1)
   [,1] [,2]
  [1,]00
  [2,]00
  [3,]00
  [4,]00
  [5,]   520
  [6,]22
  [7,]00
  [8,]20
  [9,]00
 [10,]00
 [11,]00
 [12,]00
 [13,]   540

 Works fine.
 Now I make the *same* calculation, say 1000 times:
 aaa(1000)
 R (I have tried it with R2.0.1, 2.0.0, 1.9.1, 2.1.0dev) crashes completly -
 without warning and error message under Windows XP, Intel Pentium 3 with
 256 MB RAM Under Linux SuSe 8.2 R (2.0.1) it crashes again, but in this
 case I get the following message: Calloc of 40004 bytes failed on line 114
 of file lpkit.c
 ...
 Calloc of 80008 bytes failed on line 113 of file lpkit.c
 Error: cannot allocate vector of size 3 Kb

 Now I´m completly lost. Solving the linear program one time makes no
 problem. Solving it twice in the same way makes no problem either. Running
 the same calculation, say 1000 times, causes a crash. Why should there be a
 problem with memory?

 For any hint, I would be really happy.
 Thank you,
 Matthias


 ### -- function aaa 

 aaa - function(amount=1){
 f.obj - rep(0,33)

 w - c(3,4,5,6,11,13,17,22,25,26,27,28,33)

 m -
 matrix(c(0,0,1,1,1,1,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,

  
 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,0,0,0,0,1,

  
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,

  
 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,

  
 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,

  
 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

  
 0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,1

   ),ncol=33,byrow=TRUE)

 f.dir - c(=,=,=,=,=,=,=,=,=,=,=,
 =,=,=,=,=,=,=,=,=,=,=,=,
 =,=,=,=,=,=,=,=,=,=)

 f.rhs - c(-52,0,54,0,2,0,0,0,0,0,0,0,0,0)

 lp.out - matrix( ncol = 2, nrow = 13 )

 for(ii in 1:amount){ # - simple iterate the same

 for( i in 1:13 ){

   f.obj[ w[i] ] - 1

   lp.out[ i, 1 ] - lp(min, f.obj, m, f.dir, f.rhs)$objval

   lp.out[ i, 2 ] - lp(max, f.obj, m, f.dir, f.rhs)$objval

   f.obj - rep( 0, 33 )

 }

 }
 lp.out

 }

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] nl regression with 8 parameters, help!

2005-03-23 Thread Arne Henningsen
Does this error always occur independently of the starting values that you 
provide? I guess so, because I think that the parameters in your equation are 
not identifiable, since the first term (a1 to a4) is identical to the second 
term (b1 to b4) with a1 = b1, -a2 = b2, a3 = -b3, and a4 = b4 .
Do you really want to have the same explanatory variable (Tl) in both terms?

Arne


On Wednesday 23 March 2005 16:28, Guillaume STORCHI wrote:
 I'm doing a non linear regression with 8 parameters to be fitted:

 J.Tl.nls-nls(Gw~(a1/(1+exp(-a2*Tl+a3))+a4)*(b1/(1+exp(b2*Tl-b3))+b4),data=
Enveloppe, start=list(a1=0.88957,a2=0.36298,a3=10.59241,a4=0.26308,

 b1=0.391268,b2=1.041856,b3=0.391268,b4=0.03439))

First, I fitted my curve on my data by guessing the parameters' values
 (by hand), and wrote them.
Then, I ajusted my model only with two parameters (whereas the others
 were fixed with previously found values, I did it the same way for all
 parameters. Finally, I got 8 fitted values that I enventually embedded in
 my nls() function, like above, yet R talled me:
 Error in nlsModel(formula, mf, start) : singular gradient matrix at
 initial parameter estimates

 should I use optim() or optimize()?
 How could I perform it?

 Thanks for help

 Guillaume Storchi

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RMySQL installed but not availalable

2005-03-09 Thread Arne Henningsen
NA
 KernSmooth KernSmooth /usr/lib/R/library 2.22-14 recommended NA
 latticelattice/usr/lib/R/library 0.10-14 recommended NA
 MASS   MASS   /usr/lib/R/library 7.2-10  recommended VR
 methodsmethods/usr/lib/R/library 2.0.1   baseNA
 mgcv   mgcv   /usr/lib/R/library 1.1-8   recommended NA
 nlme   nlme   /usr/lib/R/library 3.1-53  recommended NA
 nnet   nnet   /usr/lib/R/library 7.2-10  recommended VR
 RMySQL RMySQL /usr/lib/R/library 0.5-5   NANA
 rpart  rpart  /usr/lib/R/library 3.1-20  recommended NA
 spatialspatial/usr/lib/R/library 7.2-10  recommended VR
 splinessplines/usr/lib/R/library 2.0.1   baseNA
 stats  stats  /usr/lib/R/library 2.0.1   baseNA
 stats4 stats4 /usr/lib/R/library 2.0.1   baseNA
 survival   survival   /usr/lib/R/library 2.15recommended NA
 tcltk  tcltk  /usr/lib/R/library 2.0.1   baseNA
 tools  tools  /usr/lib/R/library 2.0.1   baseNA
 utils  utils  /usr/lib/R/library 2.0.1   baseNA
Depends
 base   NA
 boot   R (= 2.0.0), graphics, stats
 class  R (= 2.0.0), graphics, stats
 clusterR (= 1.9), stats, graphics, utils
 datasets   NA
 DBIR (= 1.7.1), methods
 foreignR (= 2.0.0)
 graphics   grDevices
 grDevices  NA
 grid   grDevices
 KernSmooth R (= 1.9.0)
 latticeR (= 2.0.0)
 MASS   R (= 2.0.0), graphics, stats
 methodsNA
 mgcv   R (= 1.9.0)
 nlme   graphics, stats, R(= 2.0.0)
 nnet   R (= 2.0.0), graphics, stats
 RMySQL R (= 1.8.0), methods, DBI (= 0.1-4)
 rpart  R (= 2.0.0)
 spatialR (= 2.0.0), graphics, stats
 splinesNA
 stats  NA
 stats4 graphics, stats, methods
 survival   stats, utils, graphics, splines, R (= 2.0.0)
 tcltk  NA
 tools  NA
 utils  NA
Suggests
 base   NA
 boot   survival
 class  lattice, nlme, survival
 clusterNA
 datasets   NA
 DBINA
 foreignNA
 graphics   NA
 grDevices  NA
 grid   lattice
 KernSmooth MASS
 latticegrid
 MASS   lattice, nlme, survival
 methodsNA
 mgcv   nlme (= 3.1-52), MASS (= 7.2-2)
 nlme   NA
 nnet   lattice, nlme, survival
 RMySQL NA
 rpart  survival
 spatiallattice, nlme, survival
 splinesNA
 stats  NA
 stats4 NA
 survival   NA
 tcltk  NA
 tools  NA
 utils  NA


 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] orientation of eps files

2005-03-02 Thread Arne Henningsen
I also had problems with the rotation of eps files in LaTeX presentations. 
Now, I produce eps files in R with postscript( ), 'distill' it with ps2eps, 
make a pdf with epstopdf, include it in my LaTeX file with \pgfimage{ },
use LaTeX class beamer (http://latex-beamer.sourceforge.net) and compile my 
presentation with pdflatex. This works great!

HTH,
Arne


On Wednesday 02 March 2005 14:44, Andrew Collier wrote:
 hello,

 i have a problem with the orientation of eps files produced with the
 postscript() command. i have generated some eps files with R using:

 postscript(file = filename, horizontal = FALSE, paper = special, onefile
 = F ALSE, height = height, width = width, pointsize = pointsize)

 now, when i include these eps files into a standard paper document (ie. a4
 paper, portrait orientation) everything is fine.

 however, i am now wanting to incorporate the same images into a
 presentation. i am making a pdf file, which for presentation purposes is in
 landscape orientation. i am using latex with the prosper package. images
 are included with \includegraphics{} and a pdf file is generated with
 dvipdf. however, in this case, when i include the eps figures the whole
 page suddenly gets rotated around into portrait. eps files from other
 packages seem to work fine.

 there is an example of the problem at
 ftp://chinstrap.nu.ac.za/orientation.pdf.

 if you have any ideas as to what might be causing this problem, i would be
 extremely happy to hear them.

 best regards,
 andrew.

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] [R-pkgs] New package for microeconomics: micEcon

2005-02-24 Thread Arne Henningsen
Dear all,

I have uploaded a new package called micEcon (version 0.1-3) to CRAN 
(an early version of this package has been already presented at useR! 2004).
It contains tools for microeconomic analysis and microeconomic modeling.
These are for instance:

- tools for demand analysis with the 'Almost Ideal Demand System' (AIDS): 
e.g. econometric estimation, calculation of price and income/expenditure 
elasticities, checking for theoretical consistency

- tools for production/firm analysis with the 'Symmetric Normalized 
Quadratic' (SNQ) profit function: e.g. econometric estimation, calculation of 
price elasticities and shadow prices, imposing convexity

- tools for quadratic and translog functions, e.g. econometric estimation, 
calculation of Hessians and derivatives

- functions to write input files for and read output files of Tim Coelli's 
(1996) program Frontier 4.1 (http://www.uq.edu.au/economics/cepa/ 
software.htm). In this way R can use Frontier 4.1 to perform stochastic 
frontier analysis.

- a function to perform a two-step Heckman (heckit) estimation to correct 
for non-random sample selection

- functions to calculate Laspeyres, Paasche or Fisher price and quantity 
indices


I have checked most of the functions by comparing their results with values 
published in the literature or obtained by other software. However, I cannot 
guarantee that they return correct results in all possible cases. So please 
check these functions (results, code) and send me bug reports or patches.
You are also invited to provide further functions, e.g. tools for other 
functional forms.

Best regards,
Arne


-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dim vs length for vectors

2005-01-21 Thread Arne Henningsen
On Friday 21 January 2005 06:35, Gabor Grothendieck wrote:
 In R, vectors are not arrays:

 R v - 1:4
 R dim(v)
 NULL
 R is.array(v)
 [1] FALSE

 R a - array(1:4)
 R dim(a)
 [1] 4
 R is.array(a)
 [1] TRUE

Is this a feature which is useful in some applications?
IMHO the difference between vectors and 1-dimensional arrays is really 
annoying and I had already several bugs in my code, because I mixed these up.
Is it possible in future versions of R that R does not differentiate between 
vectors and 1-dimensional arrays (e.g. by treating all vectors as 
1-dimensional arrays)?

Arne

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] systemfit - SUR

2004-11-30 Thread Arne Henningsen
On Tuesday 30 November 2004 09:34, [EMAIL PROTECTED] wrote:
 Arne Henningsen [EMAIL PROTECTED] schrieb am 29.11.2004,

 17:02:12:
  On Monday 29 November 2004 16:42, [EMAIL PROTECTED] wrote:
   Hello to everyone,
  
   I have 2 problems and would be very pleased if anyone can help me:
  
   1) When I use the package systemfit for SUR regressions, I get two
   different variance-covariance matrices when I firstly do the SUR
   regression (The covariance matrix of the residuals used for
   estimation) and secondly do the OLS regressions. In the manual for
   systemfit on page 14 I see however, that the variance-covariance
   matrix for SUR is obtained from OLS. How can this be explained?
 
  Hi Thomas,
  I get identical residual covariance matrices:
 
  R library(systemfit)
  R data( kmenta )
  R demand  supply  labels  system  fitols  fitols$rcov
   [,1] [,2]
  [1,] 3.725391 4.136963
  [2,] 4.136963 5.784441
  R fitsur  fitsur$rcovest
   [,1] [,2]
  [1,] 3.725391 4.136963
  [2,] 4.136963 5.784441

 It is a pity, but my matrices are not as nice :-(

Please show how you obtained these results. 

This is what I did:
R data( kmenta )
R demand - q ~ p + d
R supply - q ~ p + f + a
R labels - list( demand, supply )
R system - list( demand, supply )
R
R # OLS estimation:
R fitols - systemfit(OLS, system, labels, data=kmenta )
R # (non-iterated) SUR estimation
R fitsur - systemfit(SUR, system, labels, data=kmenta )
R iterated SUR estimation
R fitsurit - systemfit(SUR, system, labels, data=kmenta, maxit=100 )
R
R fitols$rcov
 [,1] [,2]
[1,] 3.725391 4.136963
[2,] 4.136963 5.784441
R fitsur$rcovest
 [,1] [,2]
[1,] 3.725391 4.136963
[2,] 4.136963 5.784441
R fitsurit$rcovest
 [,1] [,2]
[1,] 6.199071 7.493383
[2,] 7.493383 9.128547


 An excerpt:
 fitsur$rcovest
 [,1] [,2] [,3]   ...
  [1,] 0.015097517  0.018005050
  [2,] 0.018005050  0.276259834
  ...

 fitols$rcov
[,1]  [,2] [,3] ...
  [1,]  1.010326e-02  0.0096103837
  [2,]  9.610384e-03  0.2329884378
  ...

 fitsur The covariance matrix of the residuals used for estimation:
 eq1 eq2eq3 ...
 eq1 0.01317429  0.01504719 0.007981307
 eq2 0.01504719  0.25233860
 ...

 fitols The covariance matrix of the residuals:
 eq1  eq2  eq3  ...
 eq1 9.51154e-03  0.009137884  0.002648577
 eq2 9.13788e-03  0.220435063
 ...

 By the way: Why are the figures larger for SUR?

OLS minimizes the residuals and, thus, also the variance of the residuals 
(=diagonal of the residual covariance matrix).
Iterated SUR is equivalent to a maximum likelihood estimation. Maximizing the 
likelihood value is equivalent to minimizing the determinant of the residual 
covariance matrix. Thus, the determinant of the residual covariance matrix 
and not the residuals itself are minimized:

R det(fitols$rcov)
[1] 4.434845
R det(fitsurit$rcov)
[1] 0.4376941
R det(fitsurit$rcovest)
[1] 0.4377184

  Did you do _iterated_ SUR?

 Yes:
 systemfit results
 method: iterated SUR
 convergence achieved after 30 iterations

If you use iterated SUR, the SUR estimations are iterated. In the first SUR 
estimation the residual covariance matrix of the OLS estimation is used. In 
all following iterations the residual covariance matrix of the previous step 
SUR estimation is used. 

 I do not know how to change that.

Please read the documentation. It says to set argument maxit to 1 - or do 
not provide this argument, since 1 is the default.

  Best wishes,
  Arne

 THANKS A LOT FOR YOUR IMMEDIATE HELP!!!

   2) Is there an easy possibility to test a) the OLS equations, and b)
   the SUR system for SUR structures? In other words: Is the LM-Test from
   Breusch and Pagan available in R?

I don't understand what you want to test. Does the hausman test what you are 
looking for (see ?hausman.systemfit). If you have questions regarding this 
test, you might ask my co-author of systemfit, Jeff Hamann.

Best wishes,
Arne

   Thanks for the attention!
  
   Best Regards,
   Thomas Almer
  
   __
   [EMAIL PROTECTED] mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide!
   http://www.R-project.org/posting-guide.html
 
  --
  Arne Henningsen
  Department of Agricultural Economics
  University of Kiel
  Olshausenstr. 40
  D-24098 Kiel (Germany)
  Tel: +49-431-880 4445
  Fax: +49-431-880 1397
  [EMAIL PROTECTED]
  http://www.uni-kiel.de/agrarpol/ahenningsen/

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol

Re: [R] systemfit - SUR

2004-11-30 Thread Arne Henningsen
On Tuesday 30 November 2004 10:50, [EMAIL PROTECTED] wrote:
 [ . . .]
  Please show how you obtained these results.

 I did not provide the steps, because the data is not public. 

A general remark:
In most cases a questioner can use the example data provided with a package or 
construct simple data, e.g. with matrix(1:9,3). See the posting guide, 
section Examples. (If the surprising behavior does not appear with the 
sample data, the questioner has to take a deeper look in _his_ data.)

 But that is 
 what I did after defining the system and labels (like you  the
 documentation):
 fitols-systemfit(OLS, system, labels)
 fitsur-systemfit(SUR, system, labels, maxit=100)

 But after all I think your answers are sufficient. Thanks once again for
 your support. R and the community are really excellent and a big thread
 to competitors!

 [ . . . ]
 2) Is there an easy possibility to test a) the OLS equations, and
 b) the SUR system for SUR structures? In other words: Is the
 LM-Test from Breusch and Pagan available in R?
 
  I don't understand what you want to test. Does the hausman test what you
  are looking for (see ?hausman.systemfit). If you have questions regarding
  this test, you might ask my co-author of systemfit, Jeff Hamann.

 Primarily I want to test if the variance covariance matrix of the OLS
 residuals is diagonal. But this can be done manually, of course.

Please provide the code and a reference to the test. Then, I will add this 
test to systemfit. This is how R works: useRs become developerR :-)

Best wishes,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] systemfit - SUR

2004-11-29 Thread Arne Henningsen
On Monday 29 November 2004 16:42, [EMAIL PROTECTED] wrote:
 Hello to everyone,

 I have 2 problems and would be very pleased if anyone can help me:

 1) When I use the package systemfit for SUR regressions, I get two
 different variance-covariance matrices when I firstly do the SUR
 regression (The covariance matrix of the residuals used for
 estimation) and secondly do the OLS regressions. In the manual for
 systemfit on page 14 I see however, that the variance-covariance
 matrix for SUR is obtained from OLS. How can this be explained?

Hi Thomas,
I get identical residual covariance matrices:

R library(systemfit)
R data( kmenta )
R demand - q ~ p + d
R supply - q ~ p + f + a
R labels - list( demand, supply )
R system - list( demand, supply )
R fitols - systemfit(OLS, system, labels, data=kmenta )
R fitols$rcov
 [,1] [,2]
[1,] 3.725391 4.136963
[2,] 4.136963 5.784441
R fitsur - systemfit(SUR, system, labels, data=kmenta )
R fitsur$rcovest
 [,1] [,2]
[1,] 3.725391 4.136963
[2,] 4.136963 5.784441

Did you do _iterated_ SUR?

Best wishes,
Arne

 2) Is there an easy possibility to test a) the OLS equations, and b) the
 SUR system for SUR structures? In other words: Is the LM-Test from
 Breusch and Pagan available in R?

 Thanks for the attention!

 Best Regards,
 Thomas Almer

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plot problem

2004-11-29 Thread Arne Henningsen
Hi William,

the 1st example given in ?screeplot works for me (R 2.0.0 on SuSE Linux 9.0):
 (pc.cr - princomp(USArrests, cor = TRUE))  # inappropriate
 screeplot(pc.cr)
plot appears

To help you we need more details. 
Does normal plotting work? e.g.: plot(rnorm(20),rnorm(20))
Can you plot to a file? (see ?ps, ?pdf or ?png and don't forget dev.off())

Arne

On Monday 29 November 2004 13:47, william ritchie wrote:
 Dear all,

 I am having trouble plotting a PCA result. The plot doesn't appear!!!
 R goes through without any errors but doesn't make a plot appear!!
 Could it be wrong window parameters? In this case how do I change them?
 I am under red hat 9 with the latest version of R!

 Thanks.

 Vous manquez d’espace pour stocker vos mails ?

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Automatic file reading

2004-11-24 Thread Arne Henningsen
Hi Andreas,

what's about:
pair - list()
for (i in 1:8){
   name - paste(pair,i,sep=)
   pair[[ i ]] - read.table(paste(/home/andersm/tmp/,name,sep=))
}

Arne

On Wednesday 24 November 2004 12:10, Anders Malmberg wrote:
 Hi,

 I want to do automatic reading of a number of tables (files) stored in
 ascii format
 without having to specify the variable name in R each time.  Below is an
 example
 of how I would like to use it (I assume files pair1,...,pair8 exist in
 spec. dire.)

 for (i in 1:8){
   name - paste(pair,i,sep=)
   ? ? ? - read.table(paste(/home/andersm/tmp/,name,sep=))
 }

 after which I want to have pair1,...,pair8 as tables.

 But I can not get it right. Anybody having a smart solution?

 Best regards,
 Anders Malmberg

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] referencing values of strings

2004-11-17 Thread Arne Henningsen
get is your friend:

R x - c( 1, 2, 3 )
R get( x )
[1] 1 2 3

All the best,
Arne

On Wednesday 17 November 2004 16:48, Apoian, Zack wrote:
 Say you have a vector named x and a function which returns the character
 string x .  How would I take x as an input and return the vector x?


 DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}}

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to remove x, y labels from a plot

2004-11-16 Thread Arne Henningsen
Hi Jin Li,

does
   plot( 1:100, rnorm(100), ann=FALSE, xaxt=n, yaxt=n )
produce what you want?

Arne


On Tuesday 16 November 2004 13:06, [EMAIL PROTECTED] wrote:
 Hi there,



 I need to plot an illustrative figure without ticks, x, y labels in R. I
 managed to get the ticks removed, but had no luck with x, y labels.



 Any suggestions would be much appreciated.



 Jin Li




   [[alternative HTML version deleted]]

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help for nls

2004-11-15 Thread Arne Henningsen
Dear Cyrille,

type ?nls in the R command line. 
This will show you how to use the nls function.

And please read the posting guide (see bootom of each message).
This will help you to get more helpful answers.

Best wishes,
Arne

On Monday 15 November 2004 14:42, BARNERIAS Cyrille wrote:
 Hello,

 I am beginning with R and I would like to test a non linear model. But I do
 not find exactly wath I am looking for in nls packages (or I do not know
 where to search).
 I would like to try a model like this : y=b * x exp(n)/(a exp(n) + x exp
 (n))
 Where
 a = a0 + a1z
 b= b0 + b1z
 x and z are variables
 y the variable that I am trying to modelise
 a0, a1, b0 and b1 are parameters to determine.
 I am wondering if I can use nls and if so how do I have to write my command
 ?
 Thanks in advance for your help.

 Cyrille Barnérias
 Adjoint au chef d'échelon interrégional de Caen
 Inventaire forestier national
 73 rue Marie Curie
 14 200 Hérouville Saint-Clair
 France
 Tel : 02.31.47.71.53

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Creating .Rout.save files for package subdirectory tests

2004-11-05 Thread Arne Henningsen
Hi,

I added the tests subdirectory and a test file (say myTest.R) to our 
systemfit package. Up to now I create the myTest.Rout.save file with 
 R CMD BATCH --vanilla myTest.R myTest.Rout.save

However, R CMD check reports two differences between myTest.Rout.save and 
the output of myTest.R:
a) myTest.Rout.save contains following extra line at the beginning of the 
file:
 invisible(options(echo = TRUE))
b) myTest.Rout.save contains the following 2 extra lines at the very end of 
the file:
 proc.time()
[1] 1.80 0.07 2.00 0.01 0.00

Everytime I change myTest.R and create a new myTest.R.save file I have to 
delete these 3 lines by hand. I could do this e.g. by a script using sed, 
but I wonder if I can start R CMD BATCH with an option that suppresses any 
commands that are not in the input file, i.e. invisible(options(echo = 
TRUE)) and proc.time().
Or what is the easiest way to create .Rout.save files?
(I am using R 2.0.0 on a i686 PC with SuSE Linux 9.0)

Thanks,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Creating .Rout.save files for package subdirectory tests

2004-11-05 Thread Arne Henningsen
Thank you, Martin and Prof. Ripley, for your very helpful answers! 
It would be nice if this could be mentioned in section 1.1.4 of the Writing R 
Extensions manual. 
Arne

On Friday 05 November 2004 12:17, Martin Maechler wrote:
  Arne == Arne Henningsen [EMAIL PROTECTED]
  on Fri, 5 Nov 2004 11:56:02 +0100 writes:

 Arne Hi, I added the tests subdirectory and a test file
 Arne (say myTest.R) to our systemfit package. Up to now
 Arne I create the myTest.Rout.save file with

  R CMD BATCH --vanilla myTest.R myTest.Rout.save

 that explains everything.
 Why do you do so?

 Instead:

 1) Start with no '.Rout.save'

 2) R CMD check  pkg
will produce one in  pkg.Rcheck/tests/myTest.Rout
Copy it to the package source, i.e. typically

cp pkg.Rcheck/tests/myTest.Rout pkg/tests/myTest.Rout.save

 3) R CMD check  pkg
now *will* do the comparison and give no difference hopefully

 Martin Maechler, ETH Zurich


 Arne However, R CMD check reports two differences between
 Arne myTest.Rout.save and the output of myTest.R: a)
 Arne myTest.Rout.save contains following extra line at the

 Arne beginning of the file:
  invisible(options(echo = TRUE))

 Arne b) myTest.Rout.save contains the following 2 extra

 Arne lines at the very end of the file:
  proc.time()

 Arne [1] 1.80 0.07 2.00 0.01 0.00

 Arne Everytime I change myTest.R and create a new
 Arne myTest.R.save file I have to delete these 3 lines by
 Arne hand. I could do this e.g. by a script using sed,
 Arne but I wonder if I can start R CMD BATCH with an
 Arne option that suppresses any commands that are not in
 Arne the input file, i.e. invisible(options(echo = TRUE))
 Arne and proc.time().  Or what is the easiest way to
 Arne create .Rout.save files?  (I am using R 2.0.0 on a
 Arne i686 PC with SuSE Linux 9.0)

 Arne Thanks, Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] make apply() return a list

2004-11-02 Thread Arne Henningsen
Hi,

thank you very much Sundar, Patrick, Tony, Mahub and Gabor for your helpful 
answers! All your examples work great. They are all more straightforeward 
than my example and much faster than the for-loop. 
These are the average elapsed times (in seconds) returned by system.time()[3] 
(applied to my real function and my real data):

my original for-loop: 
5.55 

the example I presented in my previous email (using apply):
2.35 

example suggested by Tony (using apply):
2.34 

example suggested by Gabor (using lapply):
2.50 

examples suggested by Sundar and Mahub (using lapply):
2.68 

Best regards,
Arne


On Monday 01 November 2004 19:52, Sundar Dorai-Raj wrote:
 Arne Henningsen wrote:
  Hi,
 
  I have a dataframe (say myData) and want to get a list (say myList) that
  contains a matrix for each row of the dataframe myData. These matrices
  are calculated based on the corresponding row of myData. Using a
  for()-loop to do this is very slow. Thus, I tried to use apply().
  However, afaik apply() does only return a list if the matrices have
  different dimensions, while my matrices have all the same dimension. To
  get a list I could change the dimension of one matrix artificially and
  restore it after apply():
 
  This a (very much) simplified example of what I did:
 myData - data.frame( a = c( 1,2,3 ), b = c( 4,5,6 ) )
 myFunction - function( values ) {
 
  +myMatrix - matrix( values, 2, 2 )
  +if( all( values == myData[ 1, ] ) ) {
  +   myMatrix - cbind( myMatrix, rep( 0, 2 ) )
  +}
  +return( myMatrix )
  + }
 
 myList - apply( myData, 1, myFunction )
 myList[[ 1 ]] - myList[[ 1 ]][ 1:2, 1:2 ]
 myList
 
  $1
   [,1] [,2]
  [1,]11
  [2,]44
 
  $2
   [,1] [,2]
  [1,]22
  [2,]55
 
  $3
   [,1] [,2]
  [1,]33
  [2,]66
 
  This exactly does what I want and really speeds up the calculation, but I
  wonder if there is an easier way to make apply() return a list.
 
  Thanks for your help,
  Arne

 Hi Arne,

 I'm not sure how much faster this will be over using `for' but you can try:

 lapply(seq(nrow(myData)), function(i) myFunction(myData[i, ]))

 --sundar

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] make apply() return a list

2004-11-02 Thread Arne Henningsen
On Tuesday 02 November 2004 15:29, Gabor Grothendieck wrote:
 Arne Henningsen ahenningsen at email.uni-kiel.de writes:
 : Hi,
 :
 : thank you very much Sundar, Patrick, Tony, Mahub and Gabor for your
 : helpful answers! All your examples work great. They are all more
 : straightforeward than my example and much faster than the for-loop.
 : These are the average elapsed times (in seconds) returned by
 : system.time()

 [3]

 : (applied to my real function and my real data):
 :
 : my original for-loop:
 : 5.55
 :
 : the example I presented in my previous email (using apply):
 : 2.35
 :
 : example suggested by Tony (using apply):
 : 2.34
 :
 : example suggested by Gabor (using lapply):
 : 2.50
 :
 : examples suggested by Sundar and Mahub (using lapply):
 : 2.68

 Perhaps any comparison should also include simplicity.  

Yes, you are totally right!

 This is 
 somewhat subjective but just to objectify it I have reworked
 each solution to compactify it as much as I could and then
 calculated the number of characters in each solution using wc:

 AH - 293 characters
 TP - 70 characters
 ML - 62 characters
 GG - 48 characters

Thank you for wotking this out. I was also thinking about simplicity when I 
compared the different suggestions. Finally I took Tonys suggestion although 
the code is a bit longer than the others in _your_ comparison. The reason was 
only partially the speed, but compared to ML and GG this code preserves the 
(col)names of the dataframe, which I need in the real myFunction. 
Circumventing this small problem in ML's and GG's suggestions would make my 
code (a bit) longer than the code based on TP's suggestion.

Best wishes,
Arne

 The versions I used are below.

 ---

 # data
 myData - data.frame( a = c( 1,2,3 ), b = c( 4,5,6 ) )

 # AH
 myFunction - function( values ) {
myMatrix - matrix( values, 2, 2 )
if( all( values == myData[ 1, ] ) ) {
   myMatrix - cbind( myMatrix, rep( 0, 2 ) )
}
return( myMatrix )
 }
 myList - apply( myData, 1, myFunction )
 myList[[ 1 ]] - myList[[ 1 ]][ 1:2, 1:2 ]
 myList

 # TP
 lapply(apply(myData, 1, function(x) list(matrix(x, 2, 2))), [[, 1)

 # ML
 lapply(1:nrow(myData), function(i) matrix(myData[i,], 2, 2))

 # GG
 lapply(as.data.frame(t(myData)), matrix, 2, 2)

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] make apply() return a list

2004-11-01 Thread Arne Henningsen
Hi,

I have a dataframe (say myData) and want to get a list (say myList) that 
contains a matrix for each row of the dataframe myData. These matrices are 
calculated based on the corresponding row of myData. Using a for()-loop to do 
this is very slow. Thus, I tried to use apply(). However, afaik apply() does 
only return a list if the matrices have different dimensions, while my 
matrices have all the same dimension. To get a list I could change the 
dimension of one matrix artificially and restore it after apply():

This a (very much) simplified example of what I did:
 myData - data.frame( a = c( 1,2,3 ), b = c( 4,5,6 ) )
 myFunction - function( values ) {
+myMatrix - matrix( values, 2, 2 )
+if( all( values == myData[ 1, ] ) ) {
+   myMatrix - cbind( myMatrix, rep( 0, 2 ) )
+}
+return( myMatrix )
+ }
 myList - apply( myData, 1, myFunction )
 myList[[ 1 ]] - myList[[ 1 ]][ 1:2, 1:2 ]
 myList
$1
 [,1] [,2]
[1,]11
[2,]44

$2
 [,1] [,2]
[1,]22
[2,]55

$3
 [,1] [,2]
[1,]33
[2,]66

This exactly does what I want and really speeds up the calculation, but I 
wonder if there is an easier way to make apply() return a list.

Thanks for your help,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Q about strsplit and regexp

2004-10-20 Thread Arne Henningsen
Dear Andy,

I also don't know a regular expression that does what you want. However, if 
you have to do this several times, you can avoid the 'ugly' command by:
 mystrsplit - function( str ) strsplit(sub(^ +, , str),  +)
 mystrsplit(   a bc )
[[1]]
[1] a b c
 mystrsplit(  d  e   f)
[[1]]
[1] d e f

All the best,
Arne

On Wednesday 20 October 2004 14:15, Liaw, Andy wrote:
 Dear R-help,

 This one is probably a piece of cake for regexp masters.  I'd like to split
 a character vector (for simplicity, say of length one for now) that
 contains fields that are delimited by arbitrary number of white spaces
 (e.g.,   a b c ).  How do I get the character vector that contain the
 fields?  In the

 example I gave, I've tried:
  strsplit(  a bc ,  +)

 [[1]]
 [1]   a b c

 I do not want that empty character in the beginning, but couldn't figure
 out

 how to strip the starting white spaces, other than something ugly like:
  strsplit(sub(^ +, ,   a bc ),  +)

 [[1]]
 [1] a b c

 Can some kind soul point me to a simpler way?  TIA!!

 Best,
 Andy

 Andy Liaw, PhD
 Biometrics Research  PO Box 2000, RY33-300
 Merck Research Labs   Rahway, NJ 07065
 andy_liaw at merck.com  732-594-0820

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] A newbye question : Creating a grey palette

2004-10-05 Thread Arne Henningsen
On Monday 04 October 2004 20:04, Mike Prager wrote:
 At 11:09 AM 10/04/2004, you wrote:
 Hi all
 
 I'd like to create a grey palette for a filled.contour()
 from blank (smallest values) to black (large values)

 I have used somethig like this with bar plots:

 colvec - gray(sqrt(seq(from=0.05, to=1.0, length=ncolor)))

 That will save a color palette in colvec for use in your call.

 MHP

Another option is the package RColorBrewer:
 library(RColorBrewer)
 colvec - brewer.pal( 5, Greys )

BTW: If you start a new thread, please do not reply to an another email with a 
different subject/thread. This confuses email clients and web archives (see  
https://stat.ethz.ch/pipermail/r-help/2004-October/thread.html#57024)

Best wishes,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Strange Matrix Multiplication Behaviour

2004-10-04 Thread Arne Henningsen
Hi Wayne,

are you aware that you are NOT doing matrix multiplication? A matrix 
multiplication is done by %*%, e.g.
 tr %*% t(as.matrix(ex1)

Or do you want a normal scalar multiplication with the elements of each row of 
ex1 to be multiplied with the corresponding element of tr? However, R does 
the multiplication not row-wise, but column-wise. Thus, the results are not 
as you expected. To do a row-wise multiplication you can transform the 
data.frame:

 tr - as.vector(10*c(1:6))
 tr
[1] 10 20 30 40 50 60
 ex1 - as.data.frame(matrix(1:12,nrow=2,byrow=TRUE))
 ex1
  V1 V2 V3 V4 V5 V6
1  1  2  3  4  5  6
2  7  8  9 10 11 12
 tr * ex1
   V1  V2  V3  V4  V5  V6
1  10  60 150  40 150 300
2 140 320 540 200 440 720
 t( tr * t(ex1) )
  V1  V2  V3  V4  V5  V6
1 10  40  90 160 250 360
2 70 160 270 400 550 720
 t( tr * t(ex1) )[1,]
 V1  V2  V3  V4  V5  V6
 10  40  90 160 250 360
 t( tr * t(ex1[1,]) )
  V1 V2 V3  V4  V5  V6
1 10 40 90 160 250 360

I hope that this makes it clear.

Best wishes,
Arne


On Monday 04 October 2004 16:10, Wayne Jones wrote:
 Hi there fellow R-users,

 Im seeing some strange behaviour when I multiply a vector by a matrix

 Here is my script:
  tr

 1 2 3 4 5 6
 0.2217903 0.1560525 0.1487908 0.1671354 0.1590643 0.1471667

  ex1

a b  c  d  e  f
 1  0.2309579 -3.279045 -0.6694697 -1.1024404  0.2303928 -1.5527404
 2 -0.2865357 -2.519789 -0.1138712 -0.3571832 -2.6727913 -0.3296945

  is.vector(tr)

 [1] TRUE

  is.data.frame(ex1)

 [1] TRUE

  tr* ex1[1,]

a  b   c  d  e  f
 1 0.05122423 -0.5117031 -0.09961092 -0.1842569 0.03664727 -0.2285117

  (tr* ex1)[1,]

a  b  c  d  e  f
 1 0.05122423 -0.4878917 -0.1064887 -0.2445106 0.03428033 -0.2469855


 Notice that the output from tr * ex[1,] is different from (tr* ex1)[1,]
 Especially element number 4.

 I would naturally expect both vectors to be equivalent.


 Can anyone shed any light on my predicament??

  version

  _
 platform i386-pc-mingw32
 arch i386
 os   mingw32
 system   i386, mingw32
 status
 major1
 minor9.1
 year 2004
 month06
 day  21
 language R



 Regards

 Wayne Jones






 KSS Ltd
 Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS 
 England Company Registration Number 2800886
 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
 mailto:[EMAIL PROTECTED]  http://www.kssg.com


 The information in this Internet email is confidential and m...{{dropped}}

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: AW: [R] How to improve the quality of curve/line plots?

2004-09-24 Thread Arne Henningsen
On Friday 24 September 2004 09:35, Wolf, Michael wrote:
 Thanks for the tip using a smoothing technique before plotiing in order to
 get a curve instead of a line connecting the observations.

 But that's not the solution for my main problem with the unclean line 
plot. In order to show my problem let's take this simple example:
  xval - c(1, 2, 3, 4, 5, 6, 7, 8)
  yval - c(10, 30, 40, 50, 70, 90, 100, 110)
  plot (xval, yval, type=l)

 If you look to the result in the graphic window you will see that the line
 seems to exist of many points between the observations; e. g. between
 xval=1 and xval=2 the line contains 8 or more sublines. Perhaps, you can
 also observe a break of the line at xval=4. That's what I call an unclean
 line.

You can increase the linewidth with, e.g.:
plot (xval, yval, type=l, lwd=2)

 Even if you try to export the plot with the png command you can observe the
 same phenomenon. The line has not an exact appearance like Excel diagram
 plots. If there are no other techniques to get better line plots it seems
 to be a problem of the graphic output!?

And you can increase the resolution, e.g.:
png( myplot.png, 1000, 1000 )

Best wishes,
Arne

 Michael Wolf

 -Ursprüngliche Nachricht-
 Von: Uwe Ligges [mailto:[EMAIL PROTECTED]
 Gesendet: Freitag, 24. September 2004 09:00
 An: Wolf, Michael
 Cc: [EMAIL PROTECTED]
 Betreff: Re: [R] How to improve the quality of curve/line plots?

 Wolf, Michael wrote:
  Dear list,
 
  I'm using the windows version of R. When plotting a curve or a line for
  time series with annual data , e. g. GDP growth 1991-2003, the line seems
  to exist of a lot of smaller lines. Printing the results the curves and
  lines seems to be unclean (because of using small resolution bitmaps?).
  Comparing the result of R with the same results of Excel the lines in
  excel seems to havve a higher qualitiy. In Excel you also can produce
  curves instead of lines.
 
  Are there any possibilities how to improve the quality of the plots in R?
  How can R be influenced to plot clean lines with a higher resolution on
  the screen (I think it's not a question of the pdf- or png command.).
  Perhaps, it's a problem of the graphical possibilites of R because the
  most line plots which can be seen on the web have these problems.

 Can you specify an example please? I cannot remember any unclean plot.
 In particular, no bitmaps are used to render graphics in R.

 What I guess is that you have a line plot and each observation is connected
 with the subsequent one by a line. If you want to smooth it (and you think
 smoothing is appropriate here), you have to apply a smoothing technique
 before plotting.

 Uwe Ligges

  Thanks,
 
  Dr. Michael Wolf
  Bezirksregierung Münster
  Dezernat 61
  Domplatz 1-348161 Münster
  Tel.:   ++ 49 (02 51) / 4 11 - 17 95
  Fax.:   ++ 49 (02 51) / 4 11 - 8 17 95
  E-Mail: [EMAIL PROTECTED]
 
  __
  [EMAIL PROTECTED] mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R]

2004-09-22 Thread Arne Henningsen
help.search(upper)
chartr(base)Character Translation and Casefolding

?chartr 
refers to the function
toupper()

Best wishes,
Arne

On Wednesday 22 September 2004 10:43, [EMAIL PROTECTED] 
wrote:
 Dear Any,

 Is there a fonction in R to change a string to uppercase ?

 Thanks for all your help

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plot.Map with pattern instead of colors

2004-09-21 Thread Arne Henningsen
Dear Roger,

thank you for your valuable hints regarding plot.polylist, Map2poly and 
RColorBrewer( , Greys ). Adding pattern to some shapes with 
plot( Map2poly( x ), density = myDensities, add = TRUE ) works great!

Best wishes,
Arne

On Monday 20 September 2004 14:20, Roger Bivand wrote:
 On Mon, 20 Sep 2004, Arne Henningsen wrote:
  Hi,
 
  I am plotting shapefiles with plot.Map (package maptools). So far I use
  different colors for the shapes depending on the a value that belongs to
  the shape. Now, I need to produce maps only in black, gray and white for
  publication. Is it possible to fill shapes with pattern (e.g. hatched)
  instead of colors?

 Not in plot.Map(). This is supported if you convert the shapefile polygons
 to a polylist object (Map2poly()), then use plot.polylist() - but this may
 not be your choice. Within plot.Map, I would suggest using the
 RColorBrewer package and the sequential Greys palette, which
 differentiates five grey colours very well for most media.

 If you run this after example(plot.Map), it should illustrate a solution:

 library(RColorBrewer)
 pal - brewer.pal(5, Greys)
 fgs - pal[findInterval(x$att.data$BIR74, res$breaks, all.inside=TRUE)]
 plot(x, fg=fgs)

 for the default quantile breaks.

  Details of a simplified example:
  I want to show the percentage change of a variable in a map:
  e.g. following levels
  a) +10
  b) +5% to +10%
  c) -5% to +5%
  d) -10% to -5%
  e) -10%
 
  Now I have following colors
  a) red
  b) orange
  c) white
  d) greenyellow
  e) green3
 
  Printing this on a monochrome printer is - of course - stupid, because
  levels a) and e) as well as b) and d) have approximately the same
  grayscale. I could fill a) = black and e) = white, and everything
  inbetween with an appropriate grayscale, but I prefer to have areas with
  no change to appear white rather than medium gray. Therefore, I thought
  of doing following: a) black
  b) gray
  c) white
  d) hatched with thin lines
  e) hatched with thick lines (or double-hatched)
 
  Any hints and ideas are welcome!
  (BTW: I use R 1.9.1 on SuSE Linux 9.0)
 
  Thanks,
  Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] plot.Map with pattern instead of colors

2004-09-20 Thread Arne Henningsen
Hi,

I am plotting shapefiles with plot.Map (package maptools). So far I use 
different colors for the shapes depending on the a value that belongs to the 
shape. Now, I need to produce maps only in black, gray and white for 
publication. Is it possible to fill shapes with pattern (e.g. hatched) 
instead of colors? 

Details of a simplified example:
I want to show the percentage change of a variable in a map:
e.g. following levels
a) +10
b) +5% to +10%
c) -5% to +5%
d) -10% to -5%
e) -10%

Now I have following colors
a) red
b) orange
c) white
d) greenyellow
e) green3 

Printing this on a monochrome printer is - of course - stupid, because levels 
a) and e) as well as b) and d) have approximately the same grayscale. 
I could fill a) = black and e) = white, and everything inbetween with an 
appropriate grayscale, but I prefer to have areas with no change to appear 
white rather than medium gray. Therefore, I thought of doing following:
a) black
b) gray
c) white
d) hatched with thin lines
e) hatched with thick lines (or double-hatched)

Any hints and ideas are welcome!
(BTW: I use R 1.9.1 on SuSE Linux 9.0)

Thanks,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie needs help using R as solver

2004-09-16 Thread Arne Henningsen
On Thursday 16 September 2004 11:44, Wayne Jones wrote:
 This is a linear programming problem. Although I am not sure what your
 objective function is!!

 Check out the R package linprog

Please use the package lpSolve, it's much better and _faster_ than linprog. I 
started writing linprog before lpSolve was published. After lpSolve was on 
cran, I mainly used this package and worked only very little on linprog. 
Thus, linprog is still an alpha version. There are only few cases when 
linprog might be prefered (e.g. dual values). I hope that the next version of 
lpSolve will include these cases (then I will ask to remove linprog from 
cran).

Best wishes,
Arne

 -Original Message-
 From: Andrej Uduc [mailto:[EMAIL PROTECTED]
 Sent: 16 September 2004 10:29
 To: [EMAIL PROTECTED]
 Subject: [R] newbie needs help using R as solver

 Greetings
 I'm a total newbie in R and I'm trying to make a comparisson of Excel
 and R in the fields of:
 - optimisation modeling (using solver)
 -  decision trees
 -  simulation modeling
 as described in Winston, Wayne L.:  Practical Management Science.
 for optimisation modeling in Excel I would normaly use solver. In R
 however I can't seem to be able to find the solution. I've narrowed it
 down to optim, optimize functions (I might be totaly wrong), but I can't
 figure out how to set the conditions. I've read something about nlm
 model but I can't find the anwser (examples are not easy enough for me).
 what I wanna do is solve this simple task:
 a+b = 50
 c+d  = 50
 g  = 0,25*c+d
 a+b+c+d+g = 100
 a, b, c, d, g = 0

 I would very much appreciate any help in this matter. I need to locate
 the appropriate function for the task and figure out how to write this
 formulas. I'd also be very thankfull for any help (links) to simple
 examples of decision trees and/or simulation.

 Andrej Uduè

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


 KSS Ltd
 Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS 
 England Company Registration Number 2800886
 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
 mailto:[EMAIL PROTECTED]  http://www.kssg.com


 The information in this Internet email is confidential and m...{{dropped}}

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problems with png()

2004-09-06 Thread Arne Henningsen
On Monday 06 September 2004 12:05, Laura Quinn wrote:
 On Mon, 6 Sep 2004, Barry Rowlingson wrote:
  Laura Quinn wrote:
   I am trying to save a series of plots as .png files by using
  
   png(file=myfile.png,bg=transparent)
   dev.off()
  
   for each image plot I produce. Unfortunately when I have tried this I
   am unable to open the files, and am told they are corrupted.
  
   I have tried to use the jpeg() function but have the same problem. The
   only way I have managed to export a graphic successfully is as
   dev.copy2eps. Aside from producing unwieldy files, this is also
   unhelpful as [EMAIL PROTECTED] hoping to create a movie of the images via
   ImageMagick.
 
This sounds a bit obvious, but are you doing your plot commands
  _between_ the png() call and the dev.off() call?
 
Try:
 
png(file=foo.png)
plot(1:10)
dev.off()
 
What version/platform are you using?

 Yes, I have been using the above call to no avail. I'd be suprised if my
 libpng wasn't up-to-date on SuSe 9.0, but I'm not sure how to check which
 version I have?

I have also SuSE 9.0 and R-1.9.1, but I have no problems with png(). Did you 
compile R from source or did you install it from a rpm file?

To figure out your version of libpng type on a console:
rpm -qa libpng*

I get:
libpng-devel-1.2.5-194
libpng-1.2.5-194

libpng-devel is only necessary if you compile R from source.

You may send me the file foo.png generated by Uwes code. Then, I can try to 
open it - just to eliminate the possibility that your png viewer is broken.

Best wishes,
Arne

 Laura

  Barry

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Accesing the name of an assigned object in a function

2004-09-01 Thread Arne Henningsen
Hi Hendrik,

if I understand you right, match.call() can help you.

All the best,
Arne

On Wednesday 01 September 2004 12:13, Henrik Andersson wrote:
 I want to use the name that I assign to an object in the function that
 produces the output, somewhat like below:

 stupid.function - function(input){
  [body]
  cat(Summarized output is , output$summary, Full output isgiven
 by typing, assigned.name, \n)
  }

 assigned.name - stupid.function(whatever)


 or another example is a function that sinks the results to a text file
 and names it assigned.name.txt .

 I checked the help for function, -, assign but could not find it, is it
   possible ?


 -
 Henrik Andersson
 Netherlands Institute of Ecology -
 Centre for Estuarine and Marine Ecology
 P.O. Box 140
 4400 AC Yerseke
 Phone: +31 113 577473
 [EMAIL PROTECTED]
 http://www.nioo.knaw.nl/ppages/handersson

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Beginners Question: Make nlm work

2004-08-26 Thread Arne Henningsen
Hi,

did you try nls (nonlinear least squares)? ?nlm says: 
For nonlinear regression, 'nls' may be better.
Another option would be optim.

Best wishes,
Arne

On Thursday 26 August 2004 01:07, Johannes Graumann wrote:
 Hello,

 I'm new to this and am trying to teach myself some R by plotting
 biological data. The growth curve in question is supposed to be fitted
 to the Verhulst equation, which may be transcribed as follows:
 f(x)=a/(1+((a-0.008)/0.008)*exp(-(b*x)))
 - for a known population density (0.008) at t(0).

 I am trying to rework the example from An Introduction to R (p. 72)
 for my case and am failing miserably. Could somebody glance over the
 code below and nudge me into the right direction - I must have some
 major conceptual problem which can't be solved by me staring at it ...
 Since I'm repeating something I have done with gnuplot I know that 3 and
 4e-3 as starting values for the fit are appropriate ...

 Thanks for any hint,

 Joh

 setwd(~/Biology/R_versuch)
 mydata-read.table(YJG45-7_Growth.dat)
 x-mydata$V1
 y-mydata$V2
 VH - function(p) y ~ p[1]/(1+((p[1]-0.008)/0.008)*exp(-(p[2]*x)))
 plot(x, y, xlab=Time (h),ylab=expression(OD[600][~nm]),las=1)
 out - nlm(VH, p = c(3, 4e-3), hessian = TRUE)

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Column names of a data frame

2004-08-26 Thread Arne Henningsen
On Thursday 26 August 2004 11:31, michael watson (IAH-C) wrote:
 I'm coming out with all the classic problems today ;-)

 Can anyone tell me how to change the column names of an already existing
 data frame?  I've read the docs for ?data.frame and ?as.data.frame but
 can't figure it out.

This is a sample data frame:
 myData - data.frame( col1 = 1:3, col2 = 2:4, col3 = 3:5 )
 myData
  col1 col2 col3
1123
2234
3345

You can change all names by:
 names( myData )- c( newcol1, newcol2, newcol3 )
 myData
  newcol1 newcol2 newcol3
1   1   2   3
2   2   3   4
3   3   4   5

Or a single name by:
 names( myData )[ 2 ] - newcol2
 myData
  col1 newcol2 col3
11   23
22   34
33   45

Or if you know the name, but not the column number:
 names( myData )[ which( names( myData ) == newcol2 ) ] - verynewcol2
 myData
  col1 verynewcol2 col3
11   23
22   34
33   45

All the best,
Arne

 I want to make a new data.frame from some of the columns of an existing
 data.frame, but when I do that, the new data.frame columns have the same
 names as the old data.frame's columns, and I want them to be
 different

 Sorry for the lame question

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: how to read a file into a matrix

2004-08-26 Thread Arne Henningsen
Please read the R Data Import/Export manual. 
It should be on your harddisk and it is also available from  
http://cran.r-project.org/doc/manuals/R-data.pdf

Arne

On Thursday 26 August 2004 17:47, Gaby Aguilera wrote:
 I am trying to read a file with 8 columns and about 200 rows into a
 matrix.  I tried something like:
 x-matrix(data=data.txt, nrow=200, ncol=8) but this produces a
 matrix with data.txt in it.  Is there a way to read the data in?

 Any pointers in the right direction would be appreciated.  Thank you!

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Heckman estimation

2004-08-25 Thread Arne Henningsen
Hi,

I wrote a function to perform a two-step Heckman (also known as heckit) 
estimation. This function is mainly a wrapper function to glm (1st step 
probit estimation) and lm (2nd step OLS estimation). Though this function 
is not perfect yet, it is IMHO already very useful. Since there were some 
questions about Heckmann estimation in this list, I would like to release it 
to the public. I hope that useRs will become developeRs and help to improve 
and extend this function(s). I think it might be not very reasonable to start 
a new package just for this single small function. And my package micEcon 
for microeconomic analysis that I hope to release soon seems also not to be 
the right place, since heckman estimations are used in many other areas 
besides microeconomic analysis. Can anybody suggest me a package that is 
appropriate to include the Heckmann function and whose maintainer is willing 
to do that, too? (Of course, I will write the .Rd file and, if the maintainer 
wants, I will maintain this function.)

Thanks,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] License for including datasets in packages

2004-08-25 Thread Arne Henningsen
Dear All,

I would like to publish a function for 'heckit' estimations together with two 
examples from Greene's and Wooldridge's econometric textbooks. 
These examples use the dataset of Mroz (1987) that is also available in John 
Fox' car package. However, not all variables that are used in my examples 
are available in the car package. Therefore, I want to put the full Mroz 
dataset in my package. This full dataset can be downloaded from some internet 
sites (e.g. pages.stern.nyu.edu/~wgreene/Text/econometricanalysis.htm, 
www.stata.com/texts/eacsap/), but I did not find any license information. 

Whom do I have to ask wether I am allowed to put these data in a GPLed R 
package? (Mr. Mroz, Mr. Greene, STATA, University of Michigan (PSID), . . . )

@John: Do you have any license information on these data?

Thanks,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] sample selection problem, inverse mills ratio (Heckman, Lewbel, ...)

2004-08-23 Thread Arne Henningsen
Hi,

I think you have to do these estimations by hand. However, this shouldn't be 
too difficult. For instance the first step of the 2-step Heckman estimation 
is a probit estimation that can by done in R by 
   glm(  ... , family=binomial(link=probit))
(see ?glm). And the second step is a simple OLS regression.

All the best,
Arne


On Thursday 19 August 2004 11:45, Wildi Marc, wia wrote:
  -Ursprüngliche Nachricht-
  Von: Wildi Marc, wia
  Gesendet: Mittwoch, 18. August 2004 10:11
  An: [EMAIL PROTECTED]
  Betreff:


  Hi

  Does anybody know from an R-package devoted to sample selection problems
 (Heckman's lambda, Lewbel, ...)?

  Thanks and best regards

  Marc Wildi




  [[alternative HTML version deleted]]

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Instrumental variables

2004-08-20 Thread Arne Henningsen
The package systemfit offers instrumental variables (IV) estimation (2SLS + 
3SLS). Though this package is built to estimate equation systems, people told 
me that they use it also for single equation IV estimations (using an 
equation system that contains only one equation).

Arne

On Friday 20 August 2004 06:53, [EMAIL PROTECTED] wrote:
 May someone help me to find out how to use intruments in R?

 Thanks
 Ana

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] IDE or an Editor for R

2004-08-20 Thread Arne Henningsen
Hi SP,

I prefer to use kate (KDE advanced text editor), because it is easier to learn 
than emacs or vim and IMHO it is also very convenient to use. I have the kate 
window split into 3 parts: a) the file selector, b) the editor window, and c) 
a command line with R. I can either source() whole files or select some 
lines in the editor and execute them by a middle-click in the command line 
window. You can download the latest version of the syntax highlighting 
definitions for R from my homepage (scroll to the very bottom): 
http://www.uni-kiel.de/agrarpol/ahenningsen/index-e.html

All the best,
Arne

On Thursday 19 August 2004 20:13, S Peri wrote:
 Hi,
  Is there any IDE or any editor or any pice of code
 for .vimrc is available?

 Please let me know.

 Thanks
 SP



 ___

 Win 1 of 4,000 free domain names from Yahoo! Enter now.

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Bug in colnames of data.frames?

2004-08-17 Thread Arne Henningsen
Hi,

I am using R 1.9.1 on on i686 PC with SuSE Linux 9.0.

I have a data.frame, e.g.:

 myData - data.frame( var1 = c( 1:4 ), var2 = c (5:8 ) )

If I add a new column by

 myData$var3 - myData[ , var1 ] + myData[ , var2 ]

everything is fine, but if I omit the commas:

 myData$var4 - myData[ var1 ] + myData[ var2 ]

the name shown above the 4th column is not var4:

 myData
  var1 var2 var3 var1
11566
22688
337   10   10
448   12   12

but names() and colnames() return the expected name:

 names( myData )
[1] var1 var2 var3 var4
 colnames( myData )
[1] var1 var2 var3 var4

And it is even worse: I am not able to change the name shown above the 4th 
column:
 names( myData )[ 4 ] - var5
 myData
  var1 var2 var3 var1
11566
22688
337   10   10
448   12   12

I guess that this is a bug, isn't it?

Arne

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] (no subject)

2004-08-16 Thread Arne Henningsen
look at
 ?jpeg
PNG format might be better:
 ?png

Arne

On Monday 16 August 2004 18:48, Paolo Tommasini wrote:
 Hi there I teach a statistics class with R ( the first time ever with R)
 and some of my students have windows at home and they want to be able to
 graphs tjhey make in our college ( that only has Linux) and oopen with
 windows, I think the best wya would be saving it as a JPEG file but I
 don't know how to do it ! I only know how to do it with EPS
 dev.copy2eps(file=bla.eps)
 how can I save it as JPEG  ? or BMP any other format that is OK for
 windows ?

 thank you very much

 Paolo

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R CMD check warning on predict.systemfit

2004-03-16 Thread Arne Henningsen
Hi,

I added a new function predict.systemfit to our package systemfit to make 
it closer to other packages (e.g. lm). Now R CMD check complains that the 
generic function predict has only the argument object, while our function 
predict.systemfit has more arguments. However, the function predict.lm 
has also more arguments and they are almost the same as in 
predict.systemfit. Thus, I think that our way to specify 
predict.systemfit might be OK in spite of this warning. 
What should I do? Can I ignore this warning? 
What will Kurt answer when we submit it ;-) ?

Best wishes,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R CMD check warning on predict.systemfit

2004-03-16 Thread Arne Henningsen
Hi,

thanks, Uwe and Jari, for your helpful comments! Indeed, I forgot the ... 
argument. R did not exactly say what was wrong. It just said:

* checking S3 generic/method consistency ... WARNING
predict:
  function(object, ...)
predict.systemfit:
  function(object, data, se.fit, se.pred, interval, level)

and I wrongly assumed that data, se.fit, se.pred, interval shouldn't be 
there rather than that ... was missing.

Thanks again,
Arne

On Tuesday 16 March 2004 11:14, Jari Oksanen wrote:
 Arne,

 Are you sure that R warns about extra variables, or does it warn about
 missing parameter ...?

 The syntax of the generic is

 predict(object, ...)

 and both these should be in your function. You should have ... even if
 you do not pass any extra parameters to other functions (been there,
 seen that).

 cheers, jari oksanen

 On Tue, 2004-03-16 at 11:39, Arne Henningsen wrote:
  Hi,
 
  I added a new function predict.systemfit to our package systemfit to
  make it closer to other packages (e.g. lm). Now R CMD check complains
  that the generic function predict has only the argument object, while
  our function predict.systemfit has more arguments. However, the
  function predict.lm has also more arguments and they are almost the
  same as in
  predict.systemfit. Thus, I think that our way to specify
  predict.systemfit might be OK in spite of this warning.
  What should I do? Can I ignore this warning?
  What will Kurt answer when we submit it ;-) ?
 
  Best wishes,
  Arne

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


R for economists (was: [R] Almost Ideal Demand System)

2004-02-19 Thread Arne Henningsen
Hi,

I did not find any web page about using R in economics and econometrics so 
far. However, this does not mean that there is none (searching with google 
for R and economics gives many pages about economics and a name like 
Firstname R. Lastname on it ;-)). 
Does anybody in the list does know such a web page?
If not, I will be happy if you, Ajay, could build and maintaine one.

Best wishes,
Arne

On Sunday 15 February 2004 07:31, Ajay Shah wrote:
 Anne,

 Please do make progress on packaging and releasing your R code for
 demand analysis. Is there a web page titled R for economists! :-) If
 there isn't, I'll be happy to build and maintain one, and put a link
 to your code there.

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Almost Ideal Demand System

2004-02-13 Thread Arne Henningsen
Hi Wayne, 

I did some demand analsis with R and the systemfit package. For me it worked 
very well. Therefore, I want to prepare a new package for R that contains the 
functions to estimate the (LA-)AIDS, calculates the demand elasticities and 
so on. However, it will take me some time until this package will be ready, 
but if you are (or someone else is) interested, I can prepare an (almost 
undocumented) alpha release.

Best wishes,
Arne


On Thursday 12 February 2004 13:00, Wayne Jones wrote:
 Hi there fellow R users,


 Has anyone got an R example of applying an Ideal demand system, possibly
 using the library systemfit??


 Thanks

 Wayne


 Dr Wayne R. Jones
 Senior Statistician / Research Analyst
 KSS Limited
 St James's Buildings
 79 Oxford Street
 Manchester M1 6SS
 Tel: +44(0)161 609 4084
 Mob: +44(0)7810 523 713




 KSS Ltd
 Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS 
 England Company Registration Number 2800886
 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
 mailto:[EMAIL PROTECTED]  http://www.kssg.com


 The information in this Internet email is confidential and m...{{dropped}}

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R]Running R remotely in Windows Environment?

2004-01-29 Thread Arne Henningsen
Hi, 

I also suggest to use a Linux Server. You can work on this machine via ssh 
(e.g. with PuTTY) and transfer the input and output files with scp or a samba 
server (which is easy to install and very convenient to use for windows 
users).

Arne

On Thursday 29 January 2004 08:53, Prof Brian Ripley wrote:
 On Wed, 28 Jan 2004, Jim Porzak wrote:
  We are considering setting up a fast, RAM loaded machine as an R-server
  to handle the big problems not suitable for individual desktops and,
  also, to process ad hoc analysis requests via our portal. We are 99% a
  Windows shop, so first choice is a windows server. We'll use (D)COM for
  the portal interface and understand that.
 
  What has me stumped is how to easily interface individual analyst's
  Windows desktops to the R-server. I haven't seen anything in the
  archives, but I can't imagine this hasn't been done. What am I missing?

 R is not designed to be client-server on Windows.  People I know who do
 this use Windows Terminal Server or Citrix.

 I would question the value of this approach.  Unless you propose to run
 64-bit Windows, a `RAM loaded' machine isn't `loaded', and R under Windows
 handles large amounts of memory much less effectively than under Linux.
 64-bit Windows is uncharted territory for R, whereas 64-bit Unix/Linux is
 well trodden.

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Syntay-Highlighting for KDE-Kate

2004-01-23 Thread Arne Henningsen
Hi, 

I am the new maintainer of the R syntax highlighting plugin for kate. (The 
initial author, Egon, stopped maintaining it, because he does not use kate 
anymore.)

@ Andy: Thanks for providing the link to this file. (I was very busy this week 
and did not look at the R mailing list until today)

@ Lars: Where is the dead link on www.r-project.org?

@  Philippe: Can you please mention the R syntax highlighting file for kate 
(KDE advanced text editor) on
   http://www.sciviews.org/_rgui/projects/Editors.html
including a link to the file
   http://www.uni-kiel.de/agrarpol/ahenningsen/app-econ/R.xml

@ all: Are there other locations where this should be mentioned?

Have a nice weekend,
Arne


On Monday 19 January 2004 02:13, Liaw, Andy wrote:
 I don't use Kate, but is this what you're looking for?

 http://www.uni-kiel.de/agrarpol/ahenningsen/app-econ/R.xml

 (Found just by googling around...)

 Andy

  From: Aleksey Naumov
 
  Lars,
 
  I don't know of an R syntax plugin for Kate, instead I just use Python
  highlighting for my R scripts in Kate, and it works quite well. If you
  find an R plugin, I would appreciate a note...
 
  Thanks
  Aleksey
 
  On Sun, 18 Jan 2004, Lars Peters wrote:
   I'm looking for a plugin for Kate (or any other good text
 
  editor for linux)
 
   (KDE 3.x) which will highlight the R syntax.
  
   The link on www.r-project.org is dead!
  
   Any ideas??
  
   Thanks Lars
  
   __
   [EMAIL PROTECTED] mailing list
   https://www.stat.math.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide!
 
  http://www.R-project.org/posting-guide.html
 
 
 
 
  __
  [EMAIL PROTECTED] mailing list
  https://www.stat.math.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html

 ---
--- Notice:  This e-mail message, together with any
 attachments,...{{dropped}}

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] nonlinear regression and Excel solver

2004-01-14 Thread Arne Henningsen
Hi,

I don't know S-Plus and its functions nlminb() and ms(). However, in R I would 
use optim(), optimize or nlm(). I used these functions quiet often and had 
only very few problems. I think that R is better, easier and more flexible 
than Excel (at least in the long run), but since I don't anything about the 
Lefkovitch matrix framework I might be wrong in this case.

Best wishes,
Arne

On Wednesday 14 January 2004 19:57, Kristian Omland wrote:
 Hi all,

 Earlier today I posted this question on s-news, so apologies to some for
 the duplication.

  Please put aside your snobbery about Microsoft products for a moment.
 
  I am fitting population models to annual survey data for trout. For those
  of you familiar with ecological models, I am working in the Lefkovitch
  matrix framework; for those unfamiliar with that shorthand, the modeled
  variable is a vector of abundances of fish in five size classes, with a
  system of linear equations (represented by a matrix) governing survival,
  advancement from smaller to larger stages, and reproduction.
 
  So far, I have been using a likelihood approach in an Excel spreadsheet.
  The spreadsheet includes the annual survey data, the Lefkovitch matrix,
  and projections of the model, i.e., realizations to be compared to the
  data. It computes the negative log-likelihood of each realization
  assuming log-normally distributed noise and the sum of those likelihood
  components. I use the Solver add-in to minimize the negative
  log-likelihood over the parameters in the Lefkovitch matrix.
 
  I have made a tentative stab at using nlminb() [minor success] and ms()
  [no success] to fit the model in S-Plus, but my proficiency is such that
  I still have greater flexibility fitting the models with Excel. Thus my
  question for you all is ...
 
  Is Excels Solver an adequate tool for numerical approximation in general
  and nonlinear regression in particular? Or should I push on writing
  S-Plus code?
 
  Is anyone out there interested in assisting me with S-Plus code with the
  potential payoff of collaboration on a publication in the ecological
  literature?

 Obviously, I would be equally enthused if an R user was interested in a
 collaboration.

 Thanks in advance,
 Kristian

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R 1.8.1 on SUSE 9.0

2003-11-26 Thread Arne Henningsen
Hi,

you have to install a Fortran compiler. 
It is available on the DVD/CD as package gcc-g77.

Best wishes,
Arne

On Wednesday 26 November 2003 18:26, J.R. Lockwood wrote:
 Hello,

 I recently did a full install of SUSE 9.0 and want to get R up and
 running.  An attempted install of R-base-1.8.1-1.i586.rpm resulted in:

 
 error: Failed dependencies:
 libg2c.so.0 is needed by R-base-1.8.1-1
 

 And a ./configure in the source directory of R-1.8.1 failed with

 
 configure: error: Neither an F77 compiler nor f2c found
 

 I guess SUSE 9.0 does not come with the required fortran
 libraries/compilers.  Can someone point me in the direction of
 packages I need to install to get R running (either by installing the
 binaries or compiling from source)?  Thanks to all.

 J.R. Lockwood
 412-683-2300 x4941
 [EMAIL PROTECTED]
 http://www.rand.org/methodology/stat/members/lockwood/

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] best editor for .R files

2003-11-25 Thread Arne Henningsen
Hi Angel and * !

I also use kate and in my opinion it is very convenient. I don't know which 
features you don't like, but if you mean some syntax highlighting features, 
you might try my R syntax highlighting (XML) file for kate. It is based on 
Egon Willighagen's one and contains a few bug fixes and several extensions. 
You can download it from my homepage (http://www.uni-kiel.de/agrarpol/
ahenningsen/, the link is at the bottom of the page). 
This new file is NOT thoroughly tested so far. After testing it for some time, 
I will send it to CRAN and to kate.kde.org as an update of Egon's file, since 
Egon stopped maintaining it. 

Best wishes,
Arne


On Thursday 20 November 2003 22:27, Angel wrote:
 Which is the best editor for .R files?

 I currently use kate on my linux as it has R highlighting and allows me to
 split the window into two: in one I edit the .R file and in the other I
 have a shell so I run R and can easily  copy and paste the code. There are
 some features that I don't like and I am having a look on some
 alternatives. I've heard wonders of emacs with ess but I am a little bit
 frightened of the steep learning curve.

 What do the R experts use or would recommend using?
 Both linux and/or windows alternatives are welcomed.
 I guess it would much depend on the particular needs/preferences of each
 user but I would like to know which are the most commonly used editors.
 Thanks,
 Angel

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Symbolic math?

2003-11-17 Thread Arne Henningsen
Hi,

I sometimes use MuPAD (www.mupad.com). Unfortunately, it is not Open Source, 
but most versions are free of charge for non-commercial use (see http://
www.sciface.com/personal.shtml). 

Arne

On Monday 17 November 2003 11:37, Hank Stevens wrote:
 Hi Folks,
 I am using Windows 2000 and was wondering what (Open Source) software R
 users use or might recommend for symbolic computations (aside from the ol'
 noggin, e.g., Maxima, Mathomatic) .
 Thanks,
 Hank

 Dr. Martin Henry H. Stevens, Assistant Professor
 338 Pearson Hall
 Botany Department
 Miami University
 Oxford, OH 45056

 Office: (513) 529-4206
 Lab: (513) 529-4262
 FAX: (513) 529-4243
 http://www.cas.muohio.edu/botany/bot/henry.html
 http://www.muohio.edu/ecology

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] nlm, hessian, and derivatives in obj function?

2003-10-23 Thread Arne Henningsen
Hi,

I don't know much about non-linear models, but there is another possibility to 
fit these models: 

1) get some starting values for the parameters
2) take the derivatives of the model with respect to the parameters at the 
point of the starting values of the parameters
3) perform a linear estimation of this linearized model (using systemfit) to 
get new parameter estimates
4) got to step 2) and take these new parameter estimates in place of the 
starting values
5) iterate this until the parameters stay stable from one to the next 
iteration

This has three advantages:
1) It is not much work to write these function since systemfit already exists
2) If the model is linear in parameters, it is identical to the linearized 
model and, thus, the first iteration leads directly to the optimum
3) You get get the SEs from the last iteration of systemfit

Does this approach also have disadvantages (e.g. non-convergence of parameters 
in many cases)?

Best wishes,
Arne


On Saturday 18 October 2003 01:54, Jeff D. Hamann wrote:
 I've been working on a new package and I have a few questions regarding the
 behaviour of the nlm function. I've been (for better or worse) using the
 nlm function to fit a linear model without suppling the hessian or gradient
 attributes in the objective function. I'm curious as to why the nlm
 requires 31 iterations (for the linear model), and then it doesn't work
 when I try to add the derivative information. I know using nlm for a linear
 model isn't the optimal method, but I would like to make sure the
 parameter estimates and the se's are matching before I attempt more
 difficult problems.

 rm(list=ls(all=TRUE))
 print( running nlsystemfit models test at end...)
 data( kmenta )
 attach( kmenta )
 ##demand2 - q ~ d0 + d1 * p + d2 * d
 supply2 - q ~ s0 + s1 * p + s2 * f + s3 * a
 ##system2 - list( demand2, supply2 )
 ##labels - list( Demand, Supply )
 ##inst - ~ d + f + a
 ##sv2 - c(d0=3,s2=2.123,d2=4,s0=-2.123,s3=4.234,d1=4.234,s1=0.234)
 sv2 - c(s0=-2.123,s1=0.234,s2=2.123,s3=4.234)

 obj - function( s, eqn, data, parmnames )
 {
   ## get the values of the parameters
   for( i in 1:length( parmnames ) )
 {
   name - names( parmnames )[i]
   val - s[i]
   storage.mode( val ) -  double
   assign( name, val )
 }

   lhs - as.matrix( eval( as.formula( eqn )[[2]] ) )
   rhs - as.matrix( eval( as.formula( eqn )[[3]] ) )
   resid - crossprod( lhs - rhs )

   ## just how does this work...
   attr( obj, value ) - resid
   attr( obj, gradient ) - attr( eval( deriv3( eqn, names(
 parmnames ) ) ), gradient )

 }

 res - nlm( obj, sv2, hessian=T, eqn=supply2, data=kmenta, parmnames=sv2,
 check.analyticals=T)

 I haven't been able to get nlm to function as I keep getting the following
 error message:

 Error in nlm(obj, sv2, hessian = T, eqn = supply2, data = kmenta, parmnames
 = sv2,  :
  invalid function value in 'nlm' optimizer


 If I perform the fit without the derivative information, I get the correct
 estimates,

 $minimum
 [1] 92.55106

 $estimate
 [1] 58.2754312  0.1603666  0.2481333  0.2483023

 $gradient
 [1] 8.552542e-08 9.087699e-06 5.716032e-06 2.163105e-06

 $hessian
  [,1]   [,2] [,3] [,4]
 [1,]   40.000   4000.762   3865.0   420.00
 [2,] 4000.762 401486.918 386045.8 42007.76
 [3,] 3865.000 386045.812 379593.1 39762.40
 [4,]  420.000  42007.764  39762.4  5740.00

 $code
 [1] 1

 $iterations
 [1] 31

 I was under the impression that you could also obtain the se of the
 parameter estimates using the sqrt( diag( res$hessian ) ), but I haven't
 been able to reproduce the se computed by the Jacobian

 se - sqrt( mse * diag( solve( crossprod( J ) ) ) )# gives the correct
 results...
 hse - sqrt( ( res$minimum / 8 ) * diag( solve( res$hessian ) ) )   # gives
 similar results, but why 8?

 I've tried to put the functionality to include the jacobian and hessian in
 the objective function for nlm without success as I don't know what the
 form of the functions will be ahead of time.

 and get the se from the sqrt( diag( hessian ) ), but it's nowhere close?

 Jeff.

 ---
 Jeff D. Hamann
 Hamann, Donald and Associates, Inc.
 PO Box 1421
 Corvallis, Oregon USA 97339-1421
 (office) 541-754-1428
 (cell) 541-740-5988
 [EMAIL PROTECTED]
 www.hamanndonald.com

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Writing and running a R program

2003-10-23 Thread Arne Henningsen
source(mycode.R)

On Thursday 23 October 2003 15:29, Subramanian Karthikeyan wrote:
 Is there a way I can combine multiple lines of R commands (see below) into
 a little code snippet or a program in a text file, and run it in R to do my
 analysis?

 sink(mysink.txt)
 for (..) {
 code for creating a dataframe from supplied data
 code for doing anova from selected data
 }

 Thanks very much.

 Karth.

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] help with gsub and grep functions

2003-10-13 Thread Arne Henningsen
On Monday 13 October 2003 16:30, Martin Olivier wrote:
 Hi all,

 Let Names a vector of chatacters. For example,

   Names

 [1] g 604 be-0 -p1 (602 matches) g 606 Phli-0 -p2 (517 matches)
 [3] g 608 alu-0  (659 matches)

 I try to use gsub or grep functions for two problems :

 1. First, I would like to delete all the characters between parentheses.
 [1] g 604 be-0 -p1 g 606 be-0 -p2
 [3] g 608 be-0 -p3

 2. And, I would like to extract the characters between parentheses
 [1] 602 matches 517 matches
 [3] 659 matches


 Any idea?
 Best regards,
 Olivier

There might be a better solution, but the following commands do what you want 
(at least in the 3 cases that you showed above):

   sub( [(].*,,Names)
   sub([\)]+,,sub([^(]*[\(],,Names))

Arne

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] problem downloading Red Hat R-1.7.1-1.i386.rpm

2003-10-01 Thread Arne Henningsen
*right* click the link and then left click Save Target As (or something 
similar.

Arne 

On Wednesday 01 October 2003 08:31, Sam McClatchie wrote:
 System info:
 Red Hat 9.0
 R Version 1.7.0
 ESS 5.1.21
 Emacs 21.2.1
 ---

 Colleagues

 At work I've had to migrate from Mandrake 9.1 to Red Hat 9.0 and I'm
 reinstalling R. I am having a problem downloading from
 R-1.7.1-1.i386.rpm from /bin/linux/redhat/9/i386. Basically the download
 does not complete. I am using mozilla, and when I click on the link the
 screen corrupts with odd symbols. Is there a problem with the site? (I
 don't have any problem downloading the user-contributed packages or the
 R-1.7.1.tgz.

 Sam

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] checking generic/method consistency

2003-09-30 Thread Arne Henningsen
Hi *,

thanks for all your answers and discussions. And additionally special thanks 
to Henrik Bengtsson for writing the first draft of the R Coding 
Conventions. I think that this document contains a lot of good ideas to make 
the code more readable. Since my package is *new* code, I adjusted it 
according to most recommendations of the RCC.

However, one thing is still unclear to me: According to the RCC I gave the 
class of result of my function linProg also the name linProg, but the RCC 
says that classes must start with uppercase, while functions must start with 
lowercase, which is contradictory in this case. In one of the examples of the 
RCC, a function that returns an object with a class attribute starts with 
uppercase:
 Line - function(x0, y0, x1, y1) {
   line - list(x=c(x0,y0), y=(x1,y1));
   class(line) - Line;
   line;
 }
Does this mean that the names of these functions should start with uppercase?

Best wishes,
Arne


On Friday 26 September 2003 17:43, you wrote:
 Hi, it looks from the names of your argument that your function is a
 plain function, i.e. it is not a function specific to a class. If this
 is true, I would avoid the period and rename your function to

   solveLP - function(cvec, bvec, Amat, maximum, maxiter, verbose) ...

 Under the S3 style of programming with classes methods coupled to
 classes are written in the format

   method.class - function(object, arg1, arg2, ...

 That is, the part before the period is the name of a generic function
 and the part after is the name of the class. This is why R CMD check
 believe your that you have written a method 'solve' for class 'LP'. All
 methods named 'solve' should have a argument signature that match the
 generic function 'solve' and your solve.LP doesn't. I do not think this
 was your intention, correct? See help.start() - R Language Definition
 - Object-oriented programming: for more details about the S3 style.

 To avoid problems like these I am working on a R Coding Conventions
 (RCC), http://www.maths.lth.se/help/R/RCC/ (see Naming Conventions). It
 is an early version and not everyone agrees with it, but the intention
 is to find a style that avoid problems like yours, where it says that
 you should avoid periods in function names except if you use it for S3
 class methods. Feedback is appreciated.

 Cheers

 Henrik Bengtsson
 Lund University

  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Arne Henningsen
  Sent: den 26 september 2003 17:03
  To: [EMAIL PROTECTED]
  Subject: [R] checking generic/method consistency
 
 
  Hi,
 
  I wrote a package for linear programming and want to submit
  it to CRAN.
  Since the package 'quadprog' has a function with the name
  'solve.QP' to
  perform Quadratic Programming, I named my (main) function 'solve.LP'.
  However 'R CMD check' gives one warning:
 
  * checking generic/method consistency ... WARNING
  solve:
function(a, b, ...)
  solve.LP:
function(cvec, bvec, Amat, maximum, maxiter, verbose)
 
  while 'R CMD check' gives no warnings when the function has the name
  'solve.QP'.
 
  What do you recommend me to do?
  1) Ignore the warning and upload the package to CRAN as it is?
  2) Rename the function? (any suggestions?)
  3) Change something that avoids this problem without renaming
  the functions?
 
  I would prefer the third point, but I don't know how.
 
  Thank you for your answers,
 
  Arne
 
  --
  Arne Henningsen
  Department of Agricultural Economics
  Christian-Albrechts-University Kiel 24098 Kiel, Germany
  Tel: +49-431-880-4445
  Fax: +49-431-880-1397
  [EMAIL PROTECTED]
  http://www.uni- kiel.de/agrarpol/ahenningsen.html
 
 
 
  __
  [EMAIL PROTECTED] mailing list
  https://www.stat.math.ethz.ch/mailman/listinfo /r-help

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] checking generic/method consistency

2003-09-30 Thread Arne Henningsen
On Tuesday 30 September 2003 15:23, Martin Maechler wrote:
  Arne == Arne Henningsen [EMAIL PROTECTED]
  on Tue, 30 Sep 2003 14:18:11 +0200 writes:

 Arne Hi *,

 Arne thanks for all your answers and discussions. And
 Arne additionally special thanks to Henrik Bengtsson for
 Arne writing the first draft of the R Coding
 Arne Conventions. I think that this document contains a
 Arne lot of good ideas to make the code more
 Arne readable. Since my package is *new* code, I adjusted
 Arne it according to most recommendations of the RCC.

 Arne However, one thing is still unclear to me: According
 Arne to the RCC I gave the class of result of my function
 Arne linProg also the name linProg, but the RCC says
 Arne that classes must start with uppercase, while
 Arne functions must start with lowercase, which is
 Arne contradictory in this case. In one of the examples of
 Arne the RCC, a function that returns an object with a

 Arne class attribute starts with uppercase:
  Line - function(x0, y0, x1, y1) {
   line - list(x=c(x0,y0), y=(x1,y1));
   class(line) - Line;
   line;
  }

 do not end lines with ; in S (i.e. R or S-plus); it's
 superfluous and considered ugly by many (incl. me) and teaches
 (by example) a wrong idea.

Fortunately, I adjusted my code according to *most* (and not all) 
recommendations of the RCC and e.g. did *not* add the (also in my opinion) 
ugly semicolons.

 Arne Does this mean that the names of these functions
 Arne should start with uppercase?

 While I agree that Henrik has put up several well thought out
 recommendations {and very helpful postings such as the one you
 cite below!} , these are *Henrik*'s recommendations and are
 still subject to discussion and feedback.
 The S language has quite a long tradition and existing function
 and class base which cannot be changed mostly for compatibility
 reasons.
 One thing in this tradition is to have function foobar return
 objects of class foobar (identical spelling including case).
 This particularly applies to the old or S3 class/method system
 on which still very much of the basic S models are based.
 When using S3 classes (as you are above), I'd definitely keep
 that S tradition.

Thanks for your comment. Now I don't feel so bad if I ignore some of Henrik's 
RCCs ;-). However, I think it's important for us to agree on some coding 
conventions since the inconsistency of the syntax between R packages is a 
drawback of R (see e.g. Jeff Racine, Rob Hyndman: Using R to teach 
econometrics, Journal of Applied Econometrics 17 (2002), p. 176, 
http://www3.interscience.wiley.com/cgi-bin/fulltext/93514548/PDFSTART).
I there a discussion on R coding conventions taking place at the moment?

Best wishes,
Arne

 This naming scheme can well change when the S4 class/methods
 system is used (as it is more and more), since there, you
 construct objects rather by
   new(classname,),
   as(obj, classname, )
 etc.

 Regards,
 Martin Maechler [EMAIL PROTECTED]   http://stat.ethz.ch/~maechler/
 Seminar fuer Statistik, ETH-Zentrum  LEO C16  Leonhardstr. 27
 ETH (Federal Inst. Technology)8092 Zurich SWITZERLAND
 phone: x-41-1-632-3408fax: ...-1228   

 Arne On Friday 26 September 2003 17:43, you wrote:
  Hi, it looks from the names of your argument that your function is a
  plain function, i.e. it is not a function specific to a class. If
  this is true, I would avoid the period and rename your function to
 
  solveLP - function(cvec, bvec, Amat, maximum, maxiter, verbose) ...
 
  Under the S3 style of programming with classes methods coupled to
  classes are written in the format
 
  method.class - function(object, arg1, arg2, ...
 
  That is, the part before the period is the name of a generic
  function and the part after is the name of the class. This is why R
  CMD check believe your that you have written a method 'solve' for
  class 'LP'. All methods named 'solve' should have a argument
  signature that match the generic function 'solve' and your solve.LP
  doesn't. I do not think this was your intention, correct? See
  help.start() - R Language Definition

 - Object-oriented programming: for more details about the S3 style.

  To avoid problems like these I am working on a R Coding Conventions
  (RCC), http://www.maths.lth.se/help/R/RCC/ (see Naming Conventions).
  It is an early version and not everyone agrees with it, but the
  intention is to find a style that avoid problems like yours, where
  it says that you should avoid periods in function names except if
  you use it for S3 class methods. Feedback is appreciated.
 
  Cheers
 
  Henrik Bengtsson
  Lund University
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED

[R] checking generic/method consistency

2003-09-26 Thread Arne Henningsen
Hi,

I wrote a package for linear programming and want to submit it to CRAN. 
Since the package 'quadprog' has a function with the name 'solve.QP' to 
perform Quadratic Programming, I named my (main) function 'solve.LP'. 
However 'R CMD check' gives one warning:

* checking generic/method consistency ... WARNING
solve:
  function(a, b, ...)
solve.LP:
  function(cvec, bvec, Amat, maximum, maxiter, verbose)

while 'R CMD check' gives no warnings when the function has the name 
'solve.QP'.

What do you recommend me to do?
1) Ignore the warning and upload the package to CRAN as it is?
2) Rename the function? (any suggestions?)
3) Change something that avoids this problem without renaming the functions?

I would prefer the third point, but I don't know how.

Thank you for your answers,

Arne

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] is.numeric

2003-02-20 Thread Arne Henningsen
Hi,
I have a vector, which contains both strings and numbers, e.g.

 foo - c(str1,1234,str2,0.9876)

I want to know if a distinct element of the vector is a string or a number and 
took is.numeric, but

 is.numeric(foo[2])
[1] FALSE

because R treats the numbers in a mixed vectors as strings:

 foo
[1] str1   1234   str2   0.9876

As a workaround I use:

 !is.na(as.numeric(foo[2]))
[1] TRUE
 !is.na(as.numeric(foo[1]))
[1] FALSE
Warning message:
NAs introduced by coercion

This works, but I always get the spurious warning messages. Do you know a 
better way or a way to suppress these warning messages?

Thanks,
Arne

-- 
Arne Henningsen
Department of Agricultural Economics
Christian-Albrechts-University Kiel
24098 Kiel, Germany
Tel: +49-431-880-4445
Fax: +49-431-880-1397 
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen.html

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help