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 8994169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:21:56+00:00 2026-06-15T23:21:56+00:00

I am using Amelia to generate five new hypothetical data sets for each variable

  • 0

I am using Amelia to generate five new hypothetical data sets for each variable with missing data. Now, I want to create new variables after imputation.

The reproducible dataset is in the Zelig package.

require(Zelig)
require(Amelia)
data(freetrade)
       year    country   tariff   polity  pop        gdp.pc    ...
    1  1981    SriLanka  NA       6       14988000   461.0236 
    2  1982    SriLanka  NA       5       15189000   473.7634 
    3  1983    SriLanka  41.3     5       15417000   489.2266 

creating 5 imputed datasets with Amelia II

a.out <- amelia(freetrade, m=5, ts="year", cs="year")

transforming imputed variables

I learnt how to create transformations of the imputed variables for use in further analysis, see 4.8. in the manual.
For instance:

a.out<-transform(a.out, pol_gdp = polity * gdp-pc)  
a.out<-transform(a.out, pol.gdp = polity / gdp)  
head(a.out$imputations[[1]])

  year  country  tariff   polity pop      gdp.pc  ... pol_gdp  pol.gdp 
1 1981  SriLanka 39.55176 6      14988000 461.0236    2766.142 0.013014518  
2 1982  SriLanka 55.70500 5      15189000 473.7634    2368.817 0.010553791 
3 1983  SriLanka 41.30000 5      15417000 489.2266    2446.133 0.010220214
     ...

PROBLEM

I do not know how to create a new variable depending on the value in another variable. That is, usually I would use the if-else argument, which does however not work in Amelia.

a.out$imputations$new.var<-ifelse(a.out$imputations$polity==5,1,0)

Any ideas would be highly appreciated!

Many many thanks.

  • 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-06-15T23:21:58+00:00Added an answer on June 15, 2026 at 11:21 pm

    Many thanks to all those who started to think about how to answer this question.

    I think I have found the solution myself:

    a.out <- transform(a.out, new.var=ifelse(polity==5,1,0))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the new mvc4 now gives us access to use facebook oauth otb. I
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using System.Diagnostics.EventLog .NET type one can programmatically create logs into the Event Viewer application.
using Telerik.WinControls.Data; using Telerik.WinControls.UI.Export; namespace Directory { public partial class radForm : Form {
@using(Html.BeginForm(About, User, FormMethod.Post , new { id=aboutme})) { <fieldset> <ul> <li> <label class=block>About me</label>
using MSQL 2005 I have a continuous set of flow measurements (averaged for each
Using Soundmanager2 to get metadata is hitting troubles with flash permissions. What I want
I have a data set base_data which has missing values. I have therefore used
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
Using batch script, I want to get a first token of a line delimited

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.