[R] degree of freedom GLM

Peter Ehlers ehlers at ucalgary.ca
Tue Jul 3 00:46:09 CEST 2012


On 2012-07-02 02:37, Jennifer Kaiser wrote:
> Hi,
> I have a problem with the df.
> I read in a big csv file.
>
> Tabelle <- read.csv("C:\\Users\\Public\\Documents\\Bachelorarbeit\\eingabe8_durchnummeriert.csv" , header = T , sep=";")
>
>
> then I try this:
>
>> ygamma <- glm(Tabelle$sb_ek_ber ~1+ Tabelle$FAHRL_C + Tabelle$NUTZKREIS + Tabelle$schw_drittel_c   , family = Gamma)
>
>>   anova(ygamma, test="Chisq")
>
> Analysis of Deviance Table
>
> Model: Gamma, link: inverse
>
> Response: Tabelle$sb_ek_ber
>
> Terms added sequentially (first to last)
>
>
>                         Df Deviance Resid. Df Resid. Dev  Pr(>Chi)
> NULL                                    1236805   35451551
> Tabelle$FAHRL_C         1       33987   1236804   35417564 0.0018493 **
> Tabelle$NUTZKREIS       1      48903   1236803   35368661 0.0001880 ***
> Tabelle$schw_drittel_c   1       47328   1236802   35321334 0.0002388 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>> str(Tabelle)
> 'data.frame':   1236806 obs. of  9 variables:
>   $ Alter_Jüngster_C_inkl_AlterNutz: int  1 1 1 1 1 1 1 1 1 1 ...
>   $ ALTERKAU_C                     : int  1 2 2 1 3 3 3 4 1 1 ...
>   $ FAHRL_C                        : int  1 2 1 3 4 3 3 1 5 1 ...
>   $ NUTZKREIS                      : int  1 2 2 2 2 2 2 1 1 2 ...
>   $ RKL_U12                        : int  1 1 1 2 3 4 4 3 5 6 ...
>   $ SF_Sonder_aufgefüllt           : int  1 2 3 4 4 4 4 5 6 7 ...
>   $ schw_drittel_c                 : int  1 2 3 4 3 3 3 3 1 1 ...
>   $ sb_ek_ber                      : num  0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 ...
>   $ JE_gewichtet                   : num  0.384 3.952 3.952 2.81 3.952 ...
>
> I don't understand why the df are always 1.

You probably intended all the variables that are of
type "integer" (e.g. FAHRL_C) to be _factors_. My guess
is that, for ease of data entry, you coded these with
integers 1-7.

You'll have to tell R that you want factors:

   Tabelle$FAHRL_C <- factor(Tabelle$FAHRL_C)

etc.

Peter Ehlers

>
> it would be great if you could help me.
> 	[[alternative HTML version deleted]]
>



More information about the R-help mailing list