Plotting matrix items
by Michael Boldin
Suppose I have looped through N time series variables and have N slope
coefficients from a simple regression for each dependent variable in a Nx1
matrix.
I now want to show these as y variables in a scatter plot for a given x
variable -- in a different (and already constructed) Nx1 matrix. Can I
easily do this ?
I tricked GRETL to plot 2 new series based on the matrices as so
scalar nn=rows(bx)
smpl 2001:01 2001:01+nn-1
series y= bx
series x= mx
chart1 <- gnuplot y x --with-lines
But I'd rather not trick gretl by creating series, when the matrix values
are not actually time series.
I could export the matrices to a new dataset or export to another plotting
package or even use EXCEL, but I wonder if there is something more elegant
all in GRETL
-- i.e. create a plot directly from the matrices, independent of the
dataset design (ie. time series, cross section, panel) and current smpl
period
PS It took me some time to figure out I could only create the series y=
bx if the smpl was the exact right size -- error message was a little
obtuse. The error: 'The variable y is of type series'
A error message such as 'Can not create series from matrix unless smpl
period agrees with matrix size' would be bettter.
12 years, 10 months
multivariate ANOVA and function cdemean question
by Pindar
Hi there,
I'm trying to do multivariate ANOVA and have a bit trouble with the
following code:
<hansl>
nulldata 8
matrix Y={9,4;10,2;11,0;2,3;4,4;6,5;1,5;5,9}
matrix G={1;1;1;2;2;2;3;3}
matrix T=mcov(Y)*(rows(Y)-1)
eval T
matrix Ns =zeros(rows(uniq(G)),1)
#*How to get to the Sum of squared residuals?*
matrix Y_g1=Y[1:3,]
matrix Y_g2=Y[4:6,]
matrix Y_g3=Y[7:8,]
matrix C={}
matrix C1=mcov(Y_g1)*(rows(Y_g1)-1)
matrix C2=mcov(Y_g2)*(rows(Y_g2)-1)
matrix C3=mcov(Y_g3)*(rows(Y_g3)-1)
matrix C=C1+C2+C3
eval C
matrix C={}
loop for g=1..rows(Ns)
#C+=mcov(Y_g$g)*(rows(Y_g$g)-1)
* C+=C$g* *# this is not working*
endloop
eval C
<hansl>
Up until now I did not find a way to get to know the number of obs per
group or the indices for the the matrices matrix Y_g*.
Should work with some loop construction. However, what do you thing of
giving the function cdemean a second argument that demeans the columns
according to the structure of the groups as in G:
*C=cdemean(Y,G)'cdemean(Y,G)'
*
Cheers
Leon Unger*
*
12 years, 10 months
The Loop Mystery (differences between "loop" and "loop foreach")
by Henrique Andrade
Dear Gretl Community,
I would like to know what is wrong in the
following loops (Case 1 and Case 2):
# Case 1
loop foreach phor 0 1 2 --quiet
loop i = 1..2 --quiet
loop j = phor+1..phor+2 --quiet
scalar TESTE = $j
print TESTE
endloop
endloop
endloop
# Case 2
loop phor = 0..2 --quiet
loop i = 1..2 --quiet
loop j = phor+1..phor+2 --quiet
scalar TESTE = $j
print TESTE
endloop
endloop
endloop
As much as I know, they should present the
same result. Am I wrong?
Best regards,
Henrique Andrade*
*
12 years, 10 months
Qns
by clarodina clarodina
Have some questions
1) does gretl has a online version on a website? R has online version
2) does the ensure uniform sample size on the view-->corr implies using the
least number of sample observations? A variable has 20 sample observations
and B veriable has 26 observations choosing ensure uniform sample size
implies gretl would use the first 20 observation from both variable? what
about there are missing observations in between variable B what would gretl
use?
12 years, 10 months