Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:50:13+00:00 2026-05-26T07:50:13+00:00

I was wondering about some things in dummy.coef() which converts the estimated parameters (contrasts)

  • 0

I was wondering about some things in dummy.coef() which converts the estimated parameters (contrasts) in ANOVA models to the original ones. It only works for univariate models, but the changes required to also make it work for multivariate models seem minor. In dummy.coef.lm():

  • line 52 coef <- object$coefficients would have to be coef <- as.matrix(object$coefficients) to accomodate univariate and multivariate models (coef(object) is a vector in the 1st case, and a matrix in the 2nd)
  • line 60 ans <- drop(mm[rn == tl[j], keep, drop = FALSE] %*% coef[keep]) would have to be ans <- drop(mm[rn == tl[j], keep, drop = FALSE] %*% coef[keep, ]) to keep all columns in coef
  • line 61 names(ans) <- rnn[rn == tl[j]] could be names(ans) <- rep(rnn[rn == tl[j]], ncol(coef)) to give names to the rows of all columns

The printing method would need some changes, but that seems to be it. Does anybody know why dummy.coef() was not designed to handle multivariate models?

Another thing I stumbled upon: Lines 20-22 are

for (i in vars) args[[i]] <- if (nxl[[i]] == 1)
    rep.int(1, nl)
else factor(rep.int(xl[[i]][1L], nl), levels = xl[[i]])

Is that safe? I.e., if the if() clause is TRUE, wouldn’t there be an unexpected else? I would have expected something like

for (i in vars) args[[i]] <- if (nxl[[i]] == 1) {
    rep.int(1, nl)
} else { factor(rep.int(xl[[i]][1L], nl), levels = xl[[i]]) }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:50:13+00:00Added an answer on May 26, 2026 at 7:50 am

    This only addresses your second question (the one about the if() x else y statement at lines 20-22 in the code).

    To start with, try cut-and-pasting these two blocks into an R session:

    test <- TRUE
    
    # Block 1 -- Doesn't work
    if(test) 
        cat("test is TRUE\n")
        else
        cat("test is FALSE\n")
    
    # Block 2 -- Works
    {
    if(test) 
        cat("test is TRUE\n")
        else
        cat("test is FALSE\n")
    }
    

    What’s going on? The {} make all the difference here. Block 1 ‘read-parse-evaluates’ the code line-by-line, causing just the problem you’d expect. Block 2, on the other hand, is read and completely parsed before any evaluation takes place. That’s part of what {} directs R to do. When it receives the block of code as a whole, the parser clearly parses the if() x else y block as one expression.

    The code you quoted was taken from inside the body of a function (i.e. inside of a {} pair). In that context, it is handled correctly (i.e. like Block 2).

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been searching through StackOverflow and I'm wondering about some things regarding AdMob. I'm
Just wondering about some practice about this; I have made a simple visual C#
I was wondering about some best practices for data binding in web forms. For
I've been wondering about this problem for some time - doubleclicking a winforms TabControl's
I'm wondering about the .childNodes property, I have the code below, and for some
There are some different opinions about simple inner classes, so I was wondering if
Just trying to canvas some opinions here. I was wondering how people go about
I've started to learn Ruby recently, and was wondering about which version to learn.
I am just wondering how some things work in gamedev: I know, that the
I've read around about const and static readonly fields. We have some classes which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.