# Extract Values from Output in for loop

#### lucar

##### New Member
Dear community,

i am currently trying to extract the four parameters of a fitting output/call:

Call:
fit.gld(x = dataimportforR$Allianz[(1 + i): (270 + i)], method = "MoM") Data: dataimportforR$Allianz[(1 + i): (270 + i)] (270 obs.); Method: = mom
Parameters: 'para' = (0.002414,-1.211,-0.01284,-0.009803)
Goodness-of-fit:
Chi-Square = 47.82907, p-value = 2.748937e-07
x y
Min. :-0.07169 Min. : 0.01265
1st Qu.:-0.03059 1st Qu.: 0.32288
Median : 0.01051 Median : 1.29328
Mean : 0.01051 Mean : 6.09430
3rd Qu.: 0.05162 3rd Qu.: 9.39269
Max. : 0.09272 Max. :26.63129
This output will be generated around 5000 times. And i need the highlighted values
in a seperate table.

My for loop is:
for(i in 0:4891){
print(fit.gld(x = dataimportforR$Allianz[(1+i): (270+i)], method ="MoM")) } Thanks for any advice. Kind regards, Luca Last edited: #### JesperHP ##### TS Contributor I do not now the fit.gld() function and since its not part of base R it would be polite of you to inform others which package it is in. A fit procedure usually returns some model object which can be captured using: Code: model = fit.gld(.... whatever ....) what is printed is probably also contained in this model object. You can inspect the model object using the str() function: Code: str(model) often the model object is just a list such that the different objects in the model object can be referred to as model$ and perhaps the parameters are simply called model$par or model$parameters ..... heres and example using linear regression:

Code:
x = rnorm(100)
y = 2*x + rnorm(100)

model = lm(y ~ x)

# Looking at the first $of the printout I see something called coeffients # this is probably what I want: str(model) model model$coefficients

#### JesperHP

##### TS Contributor
Thats good to hear and you are welcome.