[Gretl-users] Problem storing scalars

Sven Schreiber svetosch at gmx.net
Wed Jun 3 07:43:50 EDT 2009


Federico Tamagni schrieb:
> Dear all,
> 
> I need to save the R_squared into a file outside gretl, and my guess is
> there is a problem on how to store scalars.
> 
> Suppose I run a simple panel regression:
> 
> panel Y const X
> 
> 
> Then, to retrieve the R_squared I use the command:
> 
> genr  R2 = $rsq
> 
> which work fine as a get the message: "Generated scalar r2 = 0.89778".

First of all, did you use R2 or r2, and consistently?

> 
> Now, in order to store this in a file, untill few weeks ago I was using
> the store command, in this way:
> 
> store --csv  path_to_myfile/my_file  r2
> 
> 
> However this does not work anymore, as I receive the following error
> message: " 'r2' is not the name of a series "
> 
> Is something changed in the way scalars are dealt with ?
> 

You could use the outfile command to redirect the output into a text file:

outfile --write path_to_myfile/my_file
print r2
outfile --close

or you could convert the scalar to a matrix, something like this:

matrix tostore = {r2}	# maybe also/only works without the braces?
mwrite(tostore,'path_to_myfile/my_file')

hth,
sven



More information about the Gretl-users mailing list